fix(NODE-7549): send afterClusterTime on writes in causally-consistent sessions#4963
Open
PavelSafronov wants to merge 1 commit into
Open
fix(NODE-7549): send afterClusterTime on writes in causally-consistent sessions#4963PavelSafronov wants to merge 1 commit into
PavelSafronov wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates session command decoration so that, in causally-consistent sessions, readConcern.afterClusterTime is also sent on write commands once an operationTime has been established, aligning write behavior with causal consistency requirements.
Changes:
- Add
commandSupportsAfterClusterTime()and use it fromapplySession()to attachafterClusterTimebeyond just read commands. - Extend the unified spec runner with a
dropDatabaseoperation for the new causal consistency test coverage. - Add/adjust unified spec tests (including new causal-consistency unified suites) to assert
afterClusterTimeon writes.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/tools/unified-spec-runner/operations.ts | Adds dropDatabase unified operation used by new causal consistency unified specs. |
| test/spec/transactions/unified/retryable-writes.yml | Updates expected command monitoring to require readConcern.afterClusterTime on retryable writes. |
| test/spec/transactions/unified/retryable-writes.json | JSON equivalent updates for retryable writes expectations. |
| test/spec/transactions/unified/commit.yml | Updates expected command monitoring to require readConcern.afterClusterTime on relevant writes. |
| test/spec/transactions/unified/commit.json | JSON equivalent updates for commit suite expectations. |
| test/spec/transactions-convenient-api/unified/callback-commits.yml | Updates expectations to require afterClusterTime in command readConcern. |
| test/spec/transactions-convenient-api/unified/callback-commits.json | JSON equivalent updates for callback commits expectations. |
| test/spec/transactions-convenient-api/unified/callback-aborts.yml | Updates expectations to require afterClusterTime in command readConcern. |
| test/spec/transactions-convenient-api/unified/callback-aborts.json | JSON equivalent updates for callback aborts expectations. |
| test/spec/causal-consistency/unified/causal-consistency-write-commands.yml | Adds new unified causal-consistency coverage for afterClusterTime on a variety of write commands. |
| test/spec/causal-consistency/unified/causal-consistency-write-commands.json | JSON equivalent of the new causal-consistency write command suite. |
| test/spec/causal-consistency/unified/causal-consistency-clientBulkWrite.yml | Adds new unified causal-consistency coverage for afterClusterTime on clientBulkWrite. |
| test/spec/causal-consistency/unified/causal-consistency-clientBulkWrite.json | JSON equivalent of the new causal-consistency clientBulkWrite suite. |
| test/integration/causal-consistency/causal_consistency.spec.test.ts | Wires the new causal-consistency unified specs into the integration test suite. |
| src/utils.ts | Introduces commandSupportsAfterClusterTime() allowlist for commands eligible for afterClusterTime. |
| src/sessions.ts | Switches causal-consistency decoration to use commandSupportsAfterClusterTime() (enabling writes). |
Comment on lines
+1088
to
+1103
| export function commandSupportsAfterClusterTime(command: Document): boolean { | ||
| // READ operations | ||
| if ( | ||
| command.aggregate || | ||
| command.count || | ||
| command.dbStats || | ||
| command.distinct || | ||
| command.find || | ||
| command.geoNear || | ||
| // command.getMore || | ||
| command.listIndexes || | ||
| command.listCollections || | ||
| command.listDatabases | ||
| ) { | ||
| return true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary of Changes
Include
afterClusterTimewith WRITE commands when in a causally-consistent session.Release Highlight
Release notes highlight
Double check the following
npm run check:lint)type(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript