-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(NODE-7549): send afterClusterTime on writes in causally-consistent sessions #4963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PavelSafronov
wants to merge
6
commits into
main
Choose a base branch
from
node-7549
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d6f46b3
fix(NODE-7549): send afterClusterTime on writes in causally-consisten…
PavelSafronov cbfe5cd
pick up latest specs
PavelSafronov 5d933c1
pr feedback: remove write commands from list
PavelSafronov 1e13a7d
Merge branch 'main' into node-7549
tadjik1 91d34dd
lint fix
PavelSafronov 39d15f2
Merge branch 'main' into node-7549
PavelSafronov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
8 changes: 8 additions & 0 deletions
8
test/integration/causal-consistency/causal_consistency.spec.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import * as path from 'path'; | ||
|
|
||
| import { loadSpecTests } from '../../spec'; | ||
| import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; | ||
|
|
||
| describe('Causal Consistency Spec - Unified', function () { | ||
| runUnifiedSuite(loadSpecTests(path.join('causal-consistency', 'unified'))); | ||
| }); |
151 changes: 151 additions & 0 deletions
151
test/spec/causal-consistency/unified/causal-consistency-clientBulkWrite.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| { | ||
| "description": "causal consistency bulkWrite include afterClusterTime", | ||
| "schemaVersion": "1.3", | ||
| "runOnRequirements": [ | ||
| { | ||
| "minServerVersion": "8.0", | ||
| "topologies": [ | ||
| "replicaset", | ||
| "sharded", | ||
| "load-balanced" | ||
| ] | ||
| } | ||
| ], | ||
| "createEntities": [ | ||
| { | ||
| "client": { | ||
| "id": "client0", | ||
| "useMultipleMongoses": false, | ||
| "uriOptions": { | ||
| "retryWrites": false | ||
| }, | ||
| "observeEvents": [ | ||
| "commandStartedEvent" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "database": { | ||
| "id": "database0", | ||
| "client": "client0", | ||
| "databaseName": "causal-consistency-tests" | ||
| } | ||
| }, | ||
| { | ||
| "collection": { | ||
| "id": "collection0", | ||
| "database": "database0", | ||
| "collectionName": "test" | ||
| } | ||
| }, | ||
| { | ||
| "session": { | ||
| "id": "session0", | ||
| "client": "client0", | ||
| "sessionOptions": { | ||
| "causalConsistency": true | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "initialData": [ | ||
| { | ||
| "collectionName": "test", | ||
| "databaseName": "causal-consistency-tests", | ||
| "documents": [ | ||
| { | ||
| "_id": 1, | ||
| "x": 11 | ||
| }, | ||
| { | ||
| "_id": 2, | ||
| "x": 22 | ||
| }, | ||
| { | ||
| "_id": 3, | ||
| "x": 33 | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "tests": [ | ||
| { | ||
| "description": "clientBulkWrite includes afterClusterTime in causally consistent session", | ||
| "operations": [ | ||
| { | ||
| "name": "find", | ||
| "object": "collection0", | ||
| "arguments": { | ||
| "session": "session0", | ||
| "filter": { | ||
| "_id": 1 | ||
| } | ||
| }, | ||
| "expectResult": [ | ||
| { | ||
| "_id": 1, | ||
| "x": 11 | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "clientBulkWrite", | ||
| "object": "client0", | ||
| "arguments": { | ||
| "session": "session0", | ||
| "models": [ | ||
| { | ||
| "insertOne": { | ||
| "namespace": "causal-consistency-tests.test", | ||
| "document": { | ||
| "_id": 4 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
| "expectEvents": [ | ||
| { | ||
| "client": "client0", | ||
| "events": [ | ||
| { | ||
| "commandStartedEvent": { | ||
| "commandName": "find", | ||
| "command": { | ||
| "find": "test", | ||
| "readConcern": { | ||
| "$$exists": false | ||
| }, | ||
| "lsid": { | ||
| "$$sessionLsid": "session0" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "commandStartedEvent": { | ||
| "commandName": "bulkWrite", | ||
| "command": { | ||
| "bulkWrite": 1, | ||
| "lsid": { | ||
| "$$sessionLsid": "session0" | ||
| }, | ||
| "readConcern": { | ||
| "afterClusterTime": { | ||
| "$$exists": true | ||
| }, | ||
| "level": { | ||
| "$$exists": false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
75 changes: 75 additions & 0 deletions
75
test/spec/causal-consistency/unified/causal-consistency-clientBulkWrite.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| description: "causal consistency bulkWrite include afterClusterTime" | ||
|
|
||
| schemaVersion: "1.3" | ||
|
|
||
| runOnRequirements: | ||
| - minServerVersion: "8.0" | ||
| topologies: [replicaset, sharded, load-balanced] | ||
|
|
||
| createEntities: | ||
| - client: | ||
| id: &client0 client0 | ||
| useMultipleMongoses: false | ||
| uriOptions: | ||
| retryWrites: false | ||
| observeEvents: [commandStartedEvent] | ||
| - database: | ||
| id: &database0 database0 | ||
| client: *client0 | ||
| databaseName: &databaseName causal-consistency-tests | ||
| - collection: | ||
| id: &collection0 collection0 | ||
| database: *database0 | ||
| collectionName: &collectionName test | ||
| - session: | ||
| id: &session0 session0 | ||
| client: *client0 | ||
| sessionOptions: | ||
| causalConsistency: true | ||
|
|
||
| initialData: | ||
| - collectionName: *collectionName | ||
| databaseName: *databaseName | ||
| documents: | ||
| - { _id: 1, x: 11 } | ||
| - { _id: 2, x: 22 } | ||
| - { _id: 3, x: 33 } | ||
|
|
||
| # In a causally consistent session, once an operationTime has been established by a prior | ||
| # operation, subsequent write commands MUST include readConcern.afterClusterTime so the | ||
| # server can apply the write causally after the previously-observed data. | ||
|
|
||
| tests: | ||
| - description: "clientBulkWrite includes afterClusterTime in causally consistent session" | ||
| operations: | ||
| - name: find | ||
| object: *collection0 | ||
| arguments: | ||
| session: *session0 | ||
| filter: { _id: 1 } | ||
| expectResult: [{ _id: 1, x: 11 }] | ||
| - name: clientBulkWrite | ||
| object: *client0 | ||
| arguments: | ||
| session: *session0 | ||
| models: | ||
| - insertOne: | ||
| namespace: causal-consistency-tests.test | ||
| document: { _id: 4 } | ||
| expectEvents: | ||
| - client: *client0 | ||
| events: | ||
| - commandStartedEvent: | ||
| commandName: find | ||
| command: | ||
| find: *collectionName | ||
| readConcern: { $$exists: false } | ||
| lsid: { $$sessionLsid: *session0 } | ||
| - commandStartedEvent: | ||
| commandName: bulkWrite | ||
| command: | ||
| bulkWrite: 1 | ||
| lsid: { $$sessionLsid: *session0 } | ||
| readConcern: | ||
| afterClusterTime: { $$exists: true } | ||
| level: { $$exists: false } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.