fix(streaming): serialize SQL Server queue commits - #10572
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a SQL Server ADO.NET streaming ordering bug where concurrent enqueues could make later MessageIds visible before earlier ones, breaking the stream cache’s monotonic sequence-token assumptions. It does so by serializing MessageId allocation + insert visibility per logical queue using a transaction-owned SQL Server application lock, and adds a focused regression test to validate the behavior.
Changes:
- Update
QueueStreamMessage(SQL Server) to acquire a per-queuesp_getapplock(transaction-owned) before allocatingNEXT VALUE FORand inserting, ensuring visibility follows allocation order per queue. - Add a SQL Server-only regression test which holds one enqueue transaction open, confirms a competing enqueue cannot proceed immediately, then validates dequeue ordering after commit.
Show a summary per file
| File | Description |
|---|---|
test/Extensions/Orleans.AdoNet.Tests/Streaming/RelationalOrleansQueriesTests.cs |
Adds a SQL Server regression verifying enqueue serialization and resulting monotonic ordering. |
src/AdoNet/Orleans.Streaming.AdoNet/SQLServer-Streaming.sql |
Serializes per-queue message ID allocation/insert using a transaction-owned application lock to preserve monotonic visibility. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
This was referenced Aug 28, 2026
Merged
Merged
This was referenced Sep 4, 2026
This was referenced Sep 7, 2026
Closed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #10568.
Concurrent SQL Server stream enqueues allocate their message IDs before their transactions commit. A later ID can therefore become visible first, allowing the pulling-agent cache to advance before an older row appears and violating its monotonic sequence-token invariant.
This change serializes message ID allocation and insertion commits per logical SQL Server queue using a transaction-owned application lock. Independent queues remain concurrent, while each queue now exposes IDs in allocation order. A focused regression holds one enqueue transaction open, verifies a competing enqueue cannot allocate an ID, then confirms dequeue order after the first commit.
Microsoft Reviewers: Open in CodeFlow