Repository navigation
fix: forward cancellation tokens in Firestore grain storage - #11414
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation consistently propagates cancellation while preserving existing concurrency behavior and includes comprehensive regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Adds cancellation-aware Firestore grain storage operations and avoids the Firestore transaction cancellation issue described in googleapis/google-cloud-dotnet#15958.
Changes:
- Forwards caller cancellation tokens through all storage operations.
- Uses a strongly consistent document read for existence checks.
- Adds deterministic cancellation and state-preservation tests.
| File | Description |
|---|---|
FirestoreGrainStorageCancellationTests.cs |
Covers cancellation, ETags, failures, and state preservation. |
FirestoreDataManager.cs |
Replaces transactional existence checks with direct document reads. |
FirestoreGrainStorage.cs |
Implements and forwards cancellation-aware overloads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: regressed. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
…1414) (cherry picked from commit 397e3b3) Upstream-PR: dotnet#11414 Upstream-Commit: 397e3b3
Firestore grain storage implements the cancellation-aware
IGrainStorageoverloads and forwards caller tokens through reads, creates, conditional and wildcard updates, deletes, and existence checks. Legacy overloads delegate withCancellationToken.None.Pre-canceled calls complete before accessing state or preparing requests. Caller-requested in-flight cancellation preserves grain state, ETags, and the original cancellation exception. Concurrency failures retain their existing classification. SDK cancellation failures with an uncanceled caller token retain write and clear error diagnostics, including legacy calls.
The existence check uses Firestore's strongly consistent single-document read with the exact caller token. This preserves its existence semantics while allowing in-flight read cancellation; Firestore 4.3.0's transaction snapshot implementation disposes its linked cancellation source before the asynchronous read completes (reported as googleapis/google-cloud-dotnet#15958).
Focused deterministic regression coverage exercises the provider through the native SDK with a fake Firestore transport across both clear modes and the ETag paths, including caller-requested and unrequested SDK cancellation.
Microsoft Reviewers: Open in CodeFlow