Azure / Azure/azure-sdk-for-rust

Cosmos: bound buffered rows across ORDER BY partition streams

Open
#4,883 0 comments 1 reaction 0 assignees View on GitHub
Client Cosmos
Dominant language
Rust
Stars
884
Forks
365
Avg merge
2d 19h
Merged PRs (30d)
109

Description

Follow-up from the [#4800](https://github.com/Azure/azure-sdk-for-rust/pull/4800) deep review.

`StreamingOrderedMerge` buffers each partition's unread rows in `ChildStream::buffered` with **no cross-child memory budget**. Worst case the node holds `partitions × maxItemCount` rows in memory, all as raw payload bytes. A slow consumer on a wide container with a large `max_item_count` can therefore pin an unbounded amount of memory, and nothing surfaces the pressure to the caller.

The current design already avoids the worst case (a child is only replenished when its buffer drains), but there is no explicit ceiling and no backpressure signal.

### Scope

- Add a configurable total buffered-row (or buffered-byte) budget across all children.
- Stop priming / replenishing once the budget is reached instead of fetching another page.
- Decide and document the behavior when the budget is smaller than one backend page.

### Validation

- A test that a low budget bounds the total buffered rows across children.
- Existing merge, resume, and split tests stay green.

Contributor guide

Open the contributing guide

Research direction

Start with StreamingOrderedMerge and ChildStream::buffered, then trace how priming and replenishment work across partition streams. Run the existing merge, resume, and split tests before adding a low-budget case that verifies total buffered rows stay within the configured limit. Done means the budget prevents further page fetches, including a documented smaller-than-page behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.