Repository navigation
GH-5107 SQL Server queue sender moves the outbox row atomically for every durable send - #5112
Merged
Merged
Conversation
…very durable send Durable sends without WasPersistedInOutbox (EF Core outbox, outbox recovery) now insert into the queue or scheduled table and delete the outbox row in one transactional batch, instead of leaving the delete to DurableSendingAgent in a second transaction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U (cherry picked from commit 49b64e2)
This was referenced Oct 23, 2026
This was referenced Oct 29, 2026
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.
Follow-up to #5107 / #5109 for the SQL Server queue sender. Independent of #5109; each database engine gets its own PR.
The gap
SqlServerQueueSender.SendAsync(Envelope)only took the atomicMoveFromOutgoingTo*path whenEnvelope.WasPersistedInOutboxwas true. Envelopes stored by the EF Core / Marten outbox and envelopes resent by outbox recovery are not marked, so they were inserted into the queue on their own and the outbox row was deleted later, in a separate transaction byDurableSendingAgent. A node that dies between the two leaves the outbox row behind; outbox recovery resends it, and once the receiver's handled inbox row has expired (KeepAfterMessageHandling) the copy is handled a second time.Fix
A durable send that isn't marked
WasPersistedInOutboxnow goes throughMoveOrWriteToQueueAsync, which writes the queue (or scheduled) row and deletes the outbox row, if there is one, in one transaction. One batch inBEGIN TRY / BEGIN TRANSACTION … COMMIT / CATCH ROLLBACK; THROW; the queue insert is skipped if the row is already there and the MERGE stays for scheduled sends. A key violation from a concurrent duplicate send (2627/2601) is treated as a duplicate. Marked envelopes keep the existing path; non-durable endpoints are unchanged. TheDurableSendingAgentdelete that follows becomes a no-op.Tests
New
Transport/Bug_5107_outbox_row_survives_the_queue_insert.cs:Before the fix 3 of 4 failed ("outbox count should be 0 but was 1"); the no-outbox-row test was the control. After: 4/4. Locally on net9.0 the provider's
Transporttests pass (130 passed, 1 skipped), andwolverine.slnxbuilds clean with-f net9.0.Refs #5107
🤖 Generated with Claude Code
https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U