Skip to content

Add native Cosmos feed cursors - #5334

Merged
Debdatta Kunda (kundadebdatta) merged 11 commits into
Azure:mainfrom
tvaron3:tvaron3-ffi-feature-gaps
Sep 29, 2026
Merged

Debdatta Kunda (kundadebdatta) merged 11 commits into
Azure:mainfrom
tvaron3:tvaron3-ffi-feature-gaps

Conversation

@tvaron3

Copy link
Copy Markdown
Member

Summary

Add an ABI-additive native cursor over the driver's retained OperationPlan, allowing queries and supported read/change feeds to advance independently of durable checkpoints.

  • Expose Open, Next, Checkpoint, and Free with complete result buffers, explicit payload shapes, and stable ownership.

  • Separate finite EOF, idle change-feed pages, and unsupported checkpoints; support wrapper-managed bounded prefetch.

  • Define queue reservations, cancellation, and delivery-loss behavior; reject legacy one-shot results that would silently truncate data.

  • Add deterministic Rust and linked C regressions, correct single-config CMake discovery, and regenerate headers/API artifacts.

  • Document the design and migration. Preserve existing read-all routing and the full-container item read-all 400/20112 rejection.

Related: [Azure/azure-sdk-for-rust#5281](#5281).

Retain driver plans across native feed pages independently of durable checkpoints. Expose complete result buffers while preserving legacy ABI layouts and rejecting incomplete one-shot results.

Add cursor lifecycle, cancellation, queue-capacity and payload ownership coverage in Rust and linked C tests. Regenerate API artifacts and document the design and wrapper-managed prefetch. Preserve existing read-feed routing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Cosmos The azure_cosmos crate label Sep 21, 2026
Preserve upstream query planning changes and cursor APIs. Adapt buffered-query tests and checkpoint status handling, regenerate merged API artifacts, and renumber the cursor design to 0029 alongside the upstream 0028 spec.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tvaron3

Copy link
Copy Markdown
Member Author

/azp run rust - cosmos - weekly

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@tvaron3
Tomas Varon (tvaron3) marked this pull request as ready for review September 22, 2026 15:07
Copilot AI balanced review requested due to automatic review settings September 22, 2026 15:07
@tvaron3
Tomas Varon (tvaron3) requested a review from a team as a code owner September 22, 2026 15:07
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Copilot review overview

🟡 Changes recommended

The public header leaks a test-only symbol, and required linked C binary-payload coverage is missing.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds retained native Cosmos feed cursors to prevent one-shot pagination truncation.

Changes:

  • Adds stateful query/read/change-feed cursor APIs with lifecycle handling.
  • Adds cursor status codes, documentation, and generated API artifacts.
  • Adds Rust and linked C regression coverage.

Public APIs:

  • Driver: adds five native cursor lifecycle and delivery sub-status constants.
  • Native ABI: adds cursor records/functions and operation-status reporting.
File Description
Cargo.lock Locks the new time dependency.
sdk/​cosmos/​docs/​specs/​0029-native-feed-cursor.md Defines the cursor design.
sdk/​cosmos/​docs/​specs/​0020-native-async-invocation.md Cross-references cursor semantics.
sdk/​cosmos/​docs/​specs/​0019-native-wrapper.md Supersedes the old pager proposal.
sdk/​cosmos/​docs/​README.md Indexes specification 0029.
sdk/​cosmos/​azure_data_cosmos_driver/​src/​error/​cosmos_status.rs Adds cursor sub-status constants.
sdk/​cosmos/​azure_data_cosmos_driver/​CHANGELOG.md Records driver API additions.
sdk/​cosmos/​azure_data_cosmos_driver/​api/​API.metadata.yml Updates API metadata hash.
sdk/​cosmos/​azure_data_cosmos_driver/​api/​API.md Records new driver constants.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​submit.rs Prevents legacy feed truncation.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​runtime.rs Makes runtime shutdown non-blocking.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​op_request.rs Supports supplied cursor operations.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​lib.rs Exports cursor modules.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​error.rs Maps cursor errors and statuses.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​cursor/​tests.rs Tests cursor lifecycle and paging.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​cursor/​fixture/​transport.rs Provides scripted transport responses.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​cursor/​fixture.rs Builds cursor test fixtures.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​cursor.rs Implements retained cursors and queues.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​cursor_request.rs Defines and validates cursor inputs.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​container_ref/​counted_tests.rs Adapts runtime fixture ownership.
sdk/​cosmos/​azure_data_cosmos_driver_native/​src/​completion.rs Adds cursor queue integration and status reporting.
sdk/​cosmos/​azure_data_cosmos_driver_native/​README.md Documents cursor usage and migration.
sdk/​cosmos/​azure_data_cosmos_driver_native/​include/​azurecosmosdriver.h Exposes the generated cursor ABI.
sdk/​cosmos/​azure_data_cosmos_driver_native/​CMakeLists.txt Fixes single-configuration output discovery.
sdk/​cosmos/​azure_data_cosmos_driver_native/​Cargo.toml Adds dependencies and test features.
sdk/​cosmos/​azure_data_cosmos_driver_native/​c_tests/​version.c Updates value-based bytes tests.
sdk/​cosmos/​azure_data_cosmos_driver_native/​c_tests/​feed_cursor.c Adds linked C cursor regressions.
sdk/​cosmos/​azure_data_cosmos_driver_native/​build.rs Adds cursor C-name mappings.
sdk/​cosmos/​azure_data_cosmos_driver_native/​api/​API.metadata.yml Updates native API metadata hash.
sdk/​cosmos/​azure_data_cosmos_driver_native/​api/​API.md Records the new native API surface.

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

Comment thread sdk/cosmos/azure_data_cosmos_driver_native/include/azurecosmosdriver.h Outdated
Comment thread sdk/cosmos/azure_data_cosmos_driver_native/c_tests/feed_cursor.c Outdated
Comment thread sdk/cosmos/azure_data_cosmos_driver/CHANGELOG.md Outdated
Comment thread sdk/cosmos/azure_data_cosmos_driver_native/src/cursor.rs Outdated
Exclude the test fixture from the generated public header through cbindgen configuration. Exercise binary DISTINCT payloads through linked C cursor tests alongside text scenarios.

Give cursor lifecycle errors appropriate messages and cover migration guidance with a regression test. Link the driver status-constant changelog entry to the upstream PR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate upstream API artifact renames and emulator/E2E updates while preserving native cursor behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Import ETAG within the emulator test module so change-feed tests compile without preview_dtx. Gate HPK patch test imports with preview_patch to keep default-feature lint clean.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate upstream main while preserving retained feed cursors. Adopt the upstream removal of handle cancellation and carry diagnostics through cursor completion ownership, retaining timeout and delivery-loss behavior.

Regenerate native headers and API artifacts and update lifecycle coverage and documentation for the merged contract.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve retained cursor support while integrating native CI coverage, preview feature updates and crate-root API artifacts. Resolve the lockfile from upstream versions plus the cursor time dependency, regenerate merged APIs and retain upstream C test cleanup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tvaron3

Copy link
Copy Markdown
Member Author

/azp run rust - cosmos - weekly

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Adapt native cursor status constants and checkpoint handling to upstream error::status_codes while preserving numeric values. Regenerate merged driver and native API artifacts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Request a fresh pipeline run without changing source files.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Tomas Varon (tvaron3) added a commit that referenced this pull request Sep 29, 2026
## Summary

The SDK-hosted httpbin service at `azuresdkforcpp.azurewebsites.net` was
intentionally retired. Core's four live HTTP transport benchmarks still
require it, causing Linux and Windows CI failures, including those
affecting #5334. This separate Core-only fix follows the explicit opt-in
approach in Azure/azure-sdk-for-cpp#7216.

- Replace the retired endpoint constant in the unpublished
`azure_core_examples` helper with validated `AZSDKRUSTTEST_HTTPBIN_URL`
configuration, add configuration tests, and regenerate its API artifact.
- Register all four live transport benchmarks only when configured. An
unset variable prints an explicit notice that no HTTP requests were
tested. Invalid configuration and request failures retain actionable
errors instead of skipping.
- Update `core_ureq_client` to require the same configuration and allow
an explicitly configured local HTTP service.
- Document the endpoint contract, commands, skip behavior, and existing
macOS exclusion in the Core README.

No fallback public endpoint or automatic server provisioning is
introduced. Offline benchmarks, published Core APIs, recorded telemetry
tests, and native cursor code remain unchanged.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate the retired-httpbin fix and native fault injection while preserving retained cursors. Resolve test features, fixture exclusions, emulator imports and documentation, then regenerate merged API artifacts.

Adapt the fault-injection fixture to runtime ownership and eager topology loading, including ETag-based range-feed completion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adopt upstream 1.0.0-beta.1 package versions while preserving native cursor fixture features and the time dependency in the merged lockfile.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@kundadebdatta Debdatta Kunda (kundadebdatta) added the Cosmos Native Wrapper Relates to the Cosmos Native Wrapper (`azure_data_cosmos_native`) label Sep 29, 2026
@kundadebdatta
Debdatta Kunda (kundadebdatta) merged commit e59c94c into Azure:main Sep 29, 2026
21 checks passed
Tomas Varon (tvaron3) added a commit that referenced this pull request Sep 30, 2026
## Summary

Fix test setup failures investigated in #5370 / weekly build 6895109 and
subsequent live runs. No production behavior or ABI changes.

- `cosmos_aad.rs`: apply a 30-second, 403/5302-only retry to the actual
AAD query and full pager consumption, rather than a separate readiness
probe. Preserve persistent RBAC failures and keep result assertions
outside retries. Cover authorization, timeout, and partial-result
handling with five deterministic regression tests.
- `cosmos_partition_merge.rs`: provision 13,000 RU/s and assert multiple
physical partitions instead of waiting for an unrelated split; retain
merge, routing, and continuation assertions.
- `tests/framework/test_client.rs`: recover from DNS outages observed in
weekly builds 6897807 and 6903164 with a 30-second DNS-only retry window
during client/database/container setup and resource cleanup. Preserve
persistent errors, do not replay test bodies or fault-injected client
construction, and retain the original test failure if cleanup also
fails. Cover recovery boundaries, error precedence, and an in-memory SDK
resource lifecycle with ten regression tests.

The original native topology mock fix is now supplied by upstream #5334
and is no longer part of this PR's diff.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 80fad27f-9c2a-4450-9ec6-a983d6d479e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cosmos Native Wrapper Relates to the Cosmos Native Wrapper (`azure_data_cosmos_native`) Cosmos The azure_cosmos crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants