Skip to content

fix(NODE-7549): send afterClusterTime on writes in causally-consistent sessions#4963

Open
PavelSafronov wants to merge 1 commit into
mainfrom
node-7549
Open

fix(NODE-7549): send afterClusterTime on writes in causally-consistent sessions#4963
PavelSafronov wants to merge 1 commit into
mainfrom
node-7549

Conversation

@PavelSafronov

@PavelSafronov PavelSafronov commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

Summary of Changes

Include afterClusterTime with WRITE commands when in a causally-consistent session.

Release Highlight

Release notes highlight

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@PavelSafronov PavelSafronov marked this pull request as ready for review June 12, 2026 14:11
@PavelSafronov PavelSafronov requested a review from a team as a code owner June 12, 2026 14:11
Copilot AI review requested due to automatic review settings June 12, 2026 14:11

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.

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 from applySession() to attach afterClusterTime beyond just read commands.
  • Extend the unified spec runner with a dropDatabase operation for the new causal consistency test coverage.
  • Add/adjust unified spec tests (including new causal-consistency unified suites) to assert afterClusterTime on 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 thread src/utils.ts
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants