Fix race condition: prevent selection of dead connection pools during node failures#3
Open
sagarrohankar-bsft wants to merge 1 commit intobsft-mainfrom
Open
Conversation
…failures Add synchronous alive checks to filter out terminated pools before selection. This fixes a race condition where pools could be selected during the async termination window after a StatusChange DOWN event. Changes: - Add filter_alive_pools/1 to check Process.alive? before pool selection - Add alive check to random_connections/1 for token ring sync - Ensures retry logic only selects from healthy, running pools Fixes race condition observed when Scylla nodes fail under load, where terminated pools remained in ConnectionRegistry during async shutdown.
merajblueshift
approved these changes
Dec 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a Scylla node fails, there's a race condition where terminated connection pools can still be selected during the async shutdown window. This happens because:
StatusChange DOWNevent triggers asyncterminate_child/2ConnectionRegistryduring terminationSolution
Add synchronous
Process.alive?/1checks to filter out dead pools before selection:filter_alive_pools/1inlib/xandra/cluster.ex(pool selection)random_connections/1inlib/xandra/clusters/cluster.ex(token ring sync)This ensures pools are only selected if the process is actually running, even if still registered.