Skip to content

fix(streaming): defer acknowledgements for batched delivery - #10655

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-fix-903-premature-message-delivery
Aug 19, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-fix-903-premature-message-delivery

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Fixes #903.

BatchContainerBatchSize > 1 advances each consumer cursor across every included queue message before awaiting the combined delivery. With SimpleQueueCache, that can leave the oldest bucket without a cursor while delivery is still in flight, allowing MessagesDeliveredAsync to acknowledge and delete those messages prematurely.

Keep the earliest cache bucket pinned for the lifetime of each combined consumer delivery. The last consumer completion releases the final pin, allowing purge and acknowledgement. Failed combined deliveries mark every contained cache item so each remains eligible for redelivery.

The regression uses two consumers blocked inside combined delivery and proves acknowledgement occurs only after both complete.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings August 18, 2026 21:23

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

This pull request fixes a streaming acknowledgement timing bug when BatchContainerBatchSize > 1 by preventing SimpleQueueCache from purging/acknowledging queue messages while a combined (batched) consumer delivery is still in-flight.

Changes:

  • Introduces an internal cursor capability (IQueueCacheCursorBatchDelivery) to scope “batched delivery” protection and failure marking.
  • Updates PersistentStreamPullingAgent to protect cache buckets across batched deliveries and to mark all items in a combined delivery as failed when delivery fails.
  • Extends SimpleQueueCacheCursor to pin the earliest cache bucket for the duration of a combined delivery and to mark specific cache items as delivery failures.
  • Adds a regression test ensuring MessagesDeliveredAsync is not called until both consumers complete their deliveries.
Show a summary per file
File Description
test/Orleans.Streaming.Tests/StreamingTests/PersistentStreamPullingAgentTests.cs Adds a regression test covering premature acknowledgement during batched consumer delivery.
src/Orleans.Streaming/QueueAdapters/IQueueCacheCursorBatchDelivery.cs Adds an internal interface for batch-delivery protection and per-batch failure recording.
src/Orleans.Streaming/PersistentStreams/PersistentStreamPullingAgent.cs Wraps batched delivery with protection and records delivery failures at batch granularity.
src/Orleans.Streaming/Common/SimpleCache/SimpleQueueCacheCursor.cs Implements batch-delivery protection by pinning the earliest bucket and supports marking specific items as delivery failures.

Review details

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

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

Keep the earliest SimpleQueueCache bucket pinned until every combined consumer delivery completes, and retain every failed container for redelivery.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 19, 2026 07:18
@ReubenBond
ReubenBond force-pushed the rb-fix-903-premature-message-delivery branch from e9c452a to 92afb72 Compare August 19, 2026 07:18

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: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@ReubenBond
ReubenBond merged commit da77fd6 into dotnet:main Aug 19, 2026
73 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-903-premature-message-delivery branch August 19, 2026 18:40
This was referenced Aug 28, 2026
This was referenced Sep 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 19, 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.

Premature call MessagesDeliveredAsync

2 participants