Skip to content

fix(cosmos): continue reminder queries after empty pages - #10276

Merged
ReubenBond merged 3 commits into
dotnet:mainfrom
vladrai:fix/issue-10273-cosmos-pagination
Aug 10, 2026
Merged

ReubenBond merged 3 commits into
dotnet:mainfrom
vladrai:fix/issue-10273-cosmos-pagination

Conversation

@vladrai

@vladrai vladrai commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

This pull request improves the reliability and maintainability of Cosmos DB reminder table operations by introducing a robust helper for draining paginated query results and refactoring the codebase to use it. The most important changes are summarized below:

Core reliability fix:

  • Added a new DrainAsync extension method in FeedIteratorExtensions.cs that fully drains a FeedIterator<T>, ensuring all items are collected across all pages, even if empty pages appear before the end. This addresses a subtle bug where iteration could previously terminate early if an empty page was encountered while more results remained.

Refactoring to use the new helper:

  • Refactored CosmosReminderTable.cs methods (ReadRows(GrainId), ReadRows(uint, uint), and TestOnlyClearTable) to use the new DrainAsync helper instead of duplicating page-draining logic. This reduces code duplication and ensures robust iteration in all cases. [1] [2] [3] [4]

Testing and validation:

  • Added comprehensive unit tests in FeedIteratorExtensionsTests.cs to verify that DrainAsync correctly handles various pagination scenarios, including empty pages in the middle, at the start, or at the end of the sequence. These tests use a custom in-memory FeedIterator to simulate edge cases that can occur in production.

Fixes #10273

Microsoft Reviewers: Open in CodeFlow

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@vladrai

vladrai commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree company="Microsoft"

@vladrai
vladrai force-pushed the fix/issue-10273-cosmos-pagination branch from b1e2f15 to 9dacfd9 Compare July 16, 2026 22:50
@ReubenBond
ReubenBond force-pushed the fix/issue-10273-cosmos-pagination branch from 9dacfd9 to 016b57e Compare August 10, 2026 20:33
@ReubenBond ReubenBond changed the title Fix/issue 10273 cosmos pagination for cross-partition queries fix(cosmos): continue reminder pagination after empty pages Aug 10, 2026
@ReubenBond ReubenBond changed the title fix(cosmos): continue reminder pagination after empty pages fix(cosmos): continue reminder queries after empty pages Aug 10, 2026
vladrai and others added 3 commits August 10, 2026 14:19
For cross-partition Cosmos queries, empty pages are valid while HasMoreResults is true.
Drain FeedIterator until HasMoreResults is false in CosmosReminderTable ReadRows methods.

Fixes dotnet#10273
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2a7080e2-0260-404d-82db-13416b40a339
@ReubenBond
ReubenBond force-pushed the fix/issue-10273-cosmos-pagination branch from 016b57e to 99eab9c Compare August 10, 2026 21:28
@ReubenBond
ReubenBond self-requested a review as a code owner August 10, 2026 21:28
@ReubenBond
ReubenBond merged commit bb6c844 into dotnet:main Aug 10, 2026
69 of 70 checks passed
This was referenced Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 10, 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.

Orphaned reminders in CosmosDB storage after silo restart.

2 participants