Skip to content

fix(streaming): preserve ADO.NET dequeue order - #10536

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-mysql-stream-timeout-60c
Aug 12, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-fix-mysql-stream-timeout-60c

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #10522.
Fixes #10458.

The ADO.NET stream pulling agent uses the first message returned for each stream as the cache cursor. MySQL selects dequeue batches in MessageId order but returns the joined rows without an ordering guarantee. PostgreSQL has the same issue because UPDATE ... RETURNING does not preserve the CTE's selection order. In preserved CI failures, affected streams produced all ten items but consumption began at sequential#2, skipping the older first row which had been returned later in the result set.

This change orders the MySQL procedure result and normalizes all ADO.NET dequeue results by MessageId, protecting existing database schemas and every provider whose result ordering is not guaranteed. It also adds a deterministic regression which supplies reverse-ordered provider results and strengthens batch coverage with concurrent enqueues.

Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 12, 2026 02:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes ADO.NET streaming dequeue ordering by ensuring GetStreamMessagesAsync returns results ordered by MessageId, addressing a MySQL-specific flake where unordered joined rows could cause the cache cursor to advance incorrectly and skip earlier items.

Changes:

  • Normalize all ADO.NET dequeue results by sorting GetStreamMessagesAsync results by MessageId.
  • Add/extend MySQL-focused regression coverage to validate ordering and increase batch coverage with concurrent enqueues.
  • Ensure the MySQL streaming dequeue procedure returns its batch in MessageId order.
Show a summary per file
File Description
test/Extensions/Orleans.AdoNet.Tests/Streaming/RelationalOrleansQueriesTests.cs Adds a MySQL regression test for provider-result ordering and strengthens dequeue-batch coverage using concurrent enqueues.
src/AdoNet/Shared/Storage/RelationalOrleansQueries.cs Sorts dequeued stream messages by MessageId to make result ordering deterministic across providers.
src/AdoNet/Orleans.Streaming.AdoNet/MySQL-Streaming.sql Adds ORDER BY M.MessageId to the MySQL dequeue procedure’s returned result set to preserve dequeue order.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Suppressed comments (1)

test/Extensions/Orleans.AdoNet.Tests/Streaming/RelationalOrleansQueriesTests.cs:422

  • This test now queues 100 messages concurrently without any throttling. For MySQL specifically, this test class is configured with a lower concurrency value, and other tests in this file explicitly gate parallel DB calls to avoid connection pool timeouts. Throttle these enqueues to concurrency to reduce flakiness.
        var acks = await Task.WhenAll(Enumerable
            .Range(0, total)
            .Select(i => _queries.QueueStreamMessageAsync(serviceId, providerId, queueId, payload, expiryTimeout))
            .ToList());
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread test/Extensions/Orleans.AdoNet.Tests/Streaming/RelationalOrleansQueriesTests.cs Outdated
Comment thread src/AdoNet/Shared/Storage/RelationalOrleansQueries.cs Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 12, 2026 03:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@ReubenBond
ReubenBond merged commit bb21b36 into dotnet:main Aug 12, 2026
198 of 202 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-mysql-stream-timeout-60c branch August 12, 2026 14:34
This was referenced Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: MySQL ADO.NET multi-stream test times out Flaky test: ADO.NET multi-stream tests time out after 30 seconds

2 participants