Repository navigation
GH-5358 Rebuild buffered and durable local queues whose receiving block faulted (supersedes #5359) - #5382
Merged
Conversation
A buffered local queue has no ListeningAgent, so once its block faulted terminally (#506) every later message was rejected until the process restarted. On the "agents" queue this left a node heartbeating while it could not run any agent command. The queue now replaces a faulted block on the next enqueue. Claude-Session: https://claude.ai/code/session_0176D1FySkqxczVGAYmFjNK7
…lt flags and a lost-envelope count Builds on Anne Erdtsieck's buffered local queue fix (#5359): - BufferedReceiver.HasFaulted and DurableReceiver.HasFaulted are backed by volatile fields. Both are set on the faulting block's thread and read without a lock on every enqueue. - When a buffered queue replaces a faulted block, the warning says how many buffered envelopes were lost (the faulted block's frozen Count). - DurableLocalQueue had the same gap: no ListeningAgent owns it, so a DurableReceiver whose block faulted (#506) was never replaced. The next enqueue now takes the faulted receiver out the way a pause does. It latches the queue, drains the receiver (which releases its rows for recovery, so nothing is lost), disposes it asynchronously, and starts a new receiver, unless a pause has taken over in the meantime. - DurableReceiver.HoldsWork ignores a faulted block's frozen Count. Otherwise a replaced faulted receiver would read as holding work and turn later blanket releases at its address into releases by id. Co-authored-by: Anne Erdtsieck <anne.erdtsieck@topicus.nl> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U
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.
Fixes #5358. This supersedes #5359 by @erdtsieck. Her commit is cherry-picked unchanged, so she stays its author, and she's credited as co-author on the follow-up commit.
The problem
When a local queue's receiving block faulted terminally (#506), the queue rejected every later message until the process restarted. Listener-backed receivers are rebuilt by
ListeningAgent/BackPressureAgent, but nothing owns a local queue that way. On theagentsqueue, that left a node heartbeating and getting agents assigned while it couldn't run a single agent command (seen in production after a managedOutOfMemoryException).Changes
From #5359 (Anne Erdtsieck), unchanged:
BufferedReceiverbuilds its block inbuildReceivingBlock(). WhenRebuildsFaultedBlockis set (onlyBufferedLocalQueuesets it), the next enqueue swaps in a new block under a lock. A late fault from a block that was already replaced is ignored.Follow-up:
BufferedReceiver.HasFaultedandDurableReceiver.HasFaultedare backed byvolatilefields. They're set on the faulting block's thread and read without a lock on every enqueue.Count).DurableLocalQueuehad the same gap, and it's closed here. On the next enqueue, a faultedDurableReceiveris taken out the way a pause takes a receiver out:ListeningAgentdisposes a faulted receiver.startAsync, which waits for that drain (L1) before it claims rows. If a pause takes over in the meantime, itsRestarterowns the restart instead.DurableReceiver.HoldsWorkignores a faulted block's frozenCount. Otherwise a replaced faulted receiver would read as holding work for as long as it lived, and every later blanket release at its address would fall back to releasing by id.Tests
faulted_buffered_local_queue(from Rebuild a buffered local queue whose receiving block faulted (#5358) #5359): a message published after the fault is handled, and theagentsqueue accepts envelopes again.faulted_durable_local_queue(new): a message published after the fault is handled by a rebuilt receiver, the queue is Accepting, and the rebuilt receiver keeps working. Both tests fail without theDurableLocalQueuechange (checked by reverting it) and pass with it.Run locally on net10.0:
faulted_*_local_queueclasses: 4/4 pass.CoreTests.Transports.Local,Runtime.WorkerQueuesandRuntime.Partitioningnamespaces: 389/389 pass.CoreTests: 4007 passed, 0 failed, 8 skipped.Wolverinebuilds with-f net9.0.CIPostgresqlcovers them.🤖 Generated with Claude Code
https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U