Repository navigation
Recycle worker connections when the fetch loop reconnects - #263
Merged
Merged
Conversation
After a silent primary loss the fetch loop hit query_timeout_seconds and reconnected, but each worker then wrote on its own idle connection to the dead primary and waited out a second timeout. Workers now track a generation bumped on every fetch-loop error; a worker whose connection predates it requeues the row, drops the connection and reconnects before running the handler.
Benchmark gate✅ gate passed
Gated (fails the build): |
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
After #262, a primary that goes silent costs two
query_timeout_seconds. First the fetch loop times out and reconnects. Then the worker gets the first post-failover row and writes it on its own idle connection to the dead primary, so the worker waits out a second timeout before anything is acknowledged.Fix
_StaleWriterError.Tradeoffs:
Verification
test_worker_recycles_writer_connection_after_fetch_loop_reconnects. It makes one fetch hang so it tripsquery_timeout_seconds, then checks that the next terminal delete runs on a different backend pid. It failed before the change (assert 102 != 102).test_publish_with_activate_in_delays_deliveryfailed once in an earlier full run; it's timing-sensitive and passed on its own 3 times and in the next full run.just test-dr, with the drill'squery_timeout_seconds=10:The blackhole number now breaks down as:
max_fetch_interval, which is 10s here;The worker no longer adds a second timeout. The docs (Database failover section and the production checklist) now describe recovery as about
query_timeout_secondsplusmax_fetch_interval.