Skip to content

fix(firestore): preserve atomic row membership reads - #11400

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-11397-firestore-torn-snapshot
Oct 3, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-11397-firestore-torn-snapshot

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #11397.

Problem

#11311 replaced the transactional point read with an unbound BatchGetDocuments stream. Under concurrent membership updates, the version document and silo row can be returned from different committed states. #11342 restored transaction protection for full-table reads but left ReadRowAsync exposed.

Solution

Run the two-document ReadRowAsync batch inside a Firestore transaction, keeping one BatchGetDocuments request per attempt while binding both documents to one serializable snapshot. Update the protocol mock to stream unbound responses lazily so it can reproduce a torn view, verify transactional selectors and retries, and identify the failing read path in emulator stress diagnostics.

Rationale

A transaction supplies the snapshot boundary which an unbound strongly consistent batch does not provide across streamed responses. Firestore retries the read when a concurrent canonical update changes its read set, preserving the membership invariant that the table version and row state come from the same commit.

Microsoft Reviewers: Open in CodeFlow

Copilot AI balanced review requested due to automatic review settings October 3, 2026 08:17

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

🟢 Approval recommended

The focused implementation preserves snapshot consistency and is covered by protocol and concurrency tests.

Review effort: Balanced
Findings: None

What changed in this PR

Makes Firestore point membership reads atomic by binding the version and silo documents to one transactional snapshot.

Changes:

  • Executes ReadRowAsync batch reads within a retryable Firestore transaction.
  • Extends protocol tests for transaction selectors, retries, failures, and cancellation.
  • Improves concurrent-read diagnostics by identifying the failing operation.
File Description
src/​Google/​Orleans.Clustering.Firestore/​FirestoreMembershipTable.cs Makes two-document row reads transactional.
test/​Extensions/​Orleans.Clustering.Firestore.Tests/​FirestoreMembershipHeartbeatTests.cs Validates transactional reads and lazy streamed-response races.
test/​Extensions/​Orleans.Clustering.Firestore.Tests/​FirestoreMembershipTableTests.cs Adds operation-specific atomicity failure diagnostics.

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

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 82.95% (115,595 / 139,357) 82.97% (115,618 / 139,353) -0.0189 pp
Branches 72.35% (33,629 / 46,479) 72.37% (33,638 / 46,479) -0.0194 pp

Report-only conclusion: regressed.

The current-main baseline is commit d114d7522a and uses the same reviewed coverage matrix.

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

@ReubenBond
ReubenBond merged commit 44b9905 into dotnet:main Oct 3, 2026
85 of 86 checks passed
@ReubenBond
ReubenBond deleted the rb-11397-firestore-torn-snapshot branch October 3, 2026 14:55
ReubenBond added a commit to ReubenBond/orleans that referenced this pull request Oct 22, 2026
ReubenBond added a commit that referenced this pull request Oct 23, 2026
(cherry picked from commit 44b9905)

Upstream-PR: #11400
Upstream-Commit: 44b9905
This was referenced Oct 29, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 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.

test(firestore): investigate torn membership snapshot during concurrent updates

2 participants