Skip to content

Commit 64233cd

Browse files
authored
CSHARP-6009: Send afterClusterTime on writes in causally-consistent sessions (#2005)
1 parent adb3d8b commit 64233cd

31 files changed

Lines changed: 2348 additions & 77 deletions
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"description": "causal consistency bulkWrite include afterClusterTime",
3+
"schemaVersion": "1.3",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "8.0",
7+
"topologies": [
8+
"replicaset",
9+
"sharded",
10+
"load-balanced"
11+
]
12+
}
13+
],
14+
"createEntities": [
15+
{
16+
"client": {
17+
"id": "client0",
18+
"useMultipleMongoses": false,
19+
"uriOptions": {
20+
"retryWrites": false
21+
},
22+
"observeEvents": [
23+
"commandStartedEvent"
24+
]
25+
}
26+
},
27+
{
28+
"database": {
29+
"id": "database0",
30+
"client": "client0",
31+
"databaseName": "causal-consistency-tests"
32+
}
33+
},
34+
{
35+
"collection": {
36+
"id": "collection0",
37+
"database": "database0",
38+
"collectionName": "test"
39+
}
40+
},
41+
{
42+
"session": {
43+
"id": "session0",
44+
"client": "client0",
45+
"sessionOptions": {
46+
"causalConsistency": true
47+
}
48+
}
49+
}
50+
],
51+
"initialData": [
52+
{
53+
"collectionName": "test",
54+
"databaseName": "causal-consistency-tests",
55+
"documents": [
56+
{
57+
"_id": 1,
58+
"x": 11
59+
},
60+
{
61+
"_id": 2,
62+
"x": 22
63+
},
64+
{
65+
"_id": 3,
66+
"x": 33
67+
}
68+
]
69+
}
70+
],
71+
"tests": [
72+
{
73+
"description": "clientBulkWrite includes afterClusterTime in causally consistent session",
74+
"operations": [
75+
{
76+
"name": "find",
77+
"object": "collection0",
78+
"arguments": {
79+
"session": "session0",
80+
"filter": {
81+
"_id": 1
82+
}
83+
},
84+
"expectResult": [
85+
{
86+
"_id": 1,
87+
"x": 11
88+
}
89+
]
90+
},
91+
{
92+
"name": "clientBulkWrite",
93+
"object": "client0",
94+
"arguments": {
95+
"session": "session0",
96+
"models": [
97+
{
98+
"insertOne": {
99+
"namespace": "causal-consistency-tests.test",
100+
"document": {
101+
"_id": 4
102+
}
103+
}
104+
}
105+
]
106+
}
107+
}
108+
],
109+
"expectEvents": [
110+
{
111+
"client": "client0",
112+
"events": [
113+
{
114+
"commandStartedEvent": {
115+
"commandName": "find",
116+
"command": {
117+
"find": "test",
118+
"readConcern": {
119+
"$$exists": false
120+
},
121+
"lsid": {
122+
"$$sessionLsid": "session0"
123+
}
124+
}
125+
}
126+
},
127+
{
128+
"commandStartedEvent": {
129+
"commandName": "bulkWrite",
130+
"command": {
131+
"bulkWrite": 1,
132+
"lsid": {
133+
"$$sessionLsid": "session0"
134+
},
135+
"readConcern": {
136+
"afterClusterTime": {
137+
"$$exists": true
138+
},
139+
"level": {
140+
"$$exists": false
141+
}
142+
}
143+
}
144+
}
145+
}
146+
]
147+
}
148+
]
149+
}
150+
]
151+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
description: "causal consistency bulkWrite include afterClusterTime"
2+
3+
schemaVersion: "1.3"
4+
5+
runOnRequirements:
6+
- minServerVersion: "8.0"
7+
topologies: [replicaset, sharded, load-balanced]
8+
9+
createEntities:
10+
- client:
11+
id: &client0 client0
12+
useMultipleMongoses: false
13+
uriOptions:
14+
retryWrites: false
15+
observeEvents: [commandStartedEvent]
16+
- database:
17+
id: &database0 database0
18+
client: *client0
19+
databaseName: &databaseName causal-consistency-tests
20+
- collection:
21+
id: &collection0 collection0
22+
database: *database0
23+
collectionName: &collectionName test
24+
- session:
25+
id: &session0 session0
26+
client: *client0
27+
sessionOptions:
28+
causalConsistency: true
29+
30+
initialData:
31+
- collectionName: *collectionName
32+
databaseName: *databaseName
33+
documents:
34+
- { _id: 1, x: 11 }
35+
- { _id: 2, x: 22 }
36+
- { _id: 3, x: 33 }
37+
38+
# In a causally consistent session, once an operationTime has been established by a prior
39+
# operation, subsequent write commands MUST include readConcern.afterClusterTime so the
40+
# server can apply the write causally after the previously-observed data.
41+
42+
tests:
43+
- description: "clientBulkWrite includes afterClusterTime in causally consistent session"
44+
operations:
45+
- name: find
46+
object: *collection0
47+
arguments:
48+
session: *session0
49+
filter: { _id: 1 }
50+
expectResult: [{ _id: 1, x: 11 }]
51+
- name: clientBulkWrite
52+
object: *client0
53+
arguments:
54+
session: *session0
55+
models:
56+
- insertOne:
57+
namespace: causal-consistency-tests.test
58+
document: { _id: 4 }
59+
expectEvents:
60+
- client: *client0
61+
events:
62+
- commandStartedEvent:
63+
commandName: find
64+
command:
65+
find: *collectionName
66+
readConcern: { $$exists: false }
67+
lsid: { $$sessionLsid: *session0 }
68+
- commandStartedEvent:
69+
commandName: bulkWrite
70+
command:
71+
bulkWrite: 1
72+
lsid: { $$sessionLsid: *session0 }
73+
readConcern:
74+
afterClusterTime: { $$exists: true }
75+
level: { $$exists: false }

0 commit comments

Comments
 (0)