Skip to content

Commit 4bc4607

Browse files
levon80999levon80999
and
levon80999
authored
PHPLIB-918: Add test that reads are not retried in a transaction (#963)
Co-authored-by: levon80999 <levonb@ucraft.com>
1 parent 0353b47 commit 4bc4607

File tree

3 files changed

+530
-0
lines changed

3 files changed

+530
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"description": "do not retry read in a transaction",
3+
"schemaVersion": "1.4",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "4.0.0",
7+
"topologies": [
8+
"replicaset"
9+
]
10+
},
11+
{
12+
"minServerVersion": "4.2.0",
13+
"topologies": [
14+
"sharded",
15+
"load-balanced"
16+
]
17+
}
18+
],
19+
"createEntities": [
20+
{
21+
"client": {
22+
"id": "client0",
23+
"useMultipleMongoses": false,
24+
"observeEvents": [
25+
"commandStartedEvent"
26+
],
27+
"uriOptions": {
28+
"retryReads": true
29+
}
30+
}
31+
},
32+
{
33+
"database": {
34+
"id": "database0",
35+
"client": "client0",
36+
"databaseName": "retryable-read-in-transaction-test"
37+
}
38+
},
39+
{
40+
"collection": {
41+
"id": "collection0",
42+
"database": "database0",
43+
"collectionName": "coll"
44+
}
45+
},
46+
{
47+
"session": {
48+
"id": "session0",
49+
"client": "client0"
50+
}
51+
}
52+
],
53+
"tests": [
54+
{
55+
"description": "find does not retry in a transaction",
56+
"operations": [
57+
{
58+
"name": "startTransaction",
59+
"object": "session0"
60+
},
61+
{
62+
"name": "failPoint",
63+
"object": "testRunner",
64+
"arguments": {
65+
"client": "client0",
66+
"failPoint": {
67+
"configureFailPoint": "failCommand",
68+
"mode": {
69+
"times": 1
70+
},
71+
"data": {
72+
"failCommands": [
73+
"find"
74+
],
75+
"closeConnection": true
76+
}
77+
}
78+
}
79+
},
80+
{
81+
"name": "find",
82+
"object": "collection0",
83+
"arguments": {
84+
"filter": {},
85+
"session": "session0"
86+
},
87+
"expectError": {
88+
"isError": true,
89+
"errorLabelsContain": [
90+
"TransientTransactionError"
91+
]
92+
}
93+
}
94+
],
95+
"expectEvents": [
96+
{
97+
"client": "client0",
98+
"events": [
99+
{
100+
"commandStartedEvent": {
101+
"command": {
102+
"find": "coll",
103+
"filter": {},
104+
"startTransaction": true
105+
},
106+
"commandName": "find",
107+
"databaseName": "retryable-read-in-transaction-test"
108+
}
109+
}
110+
]
111+
}
112+
]
113+
}
114+
]
115+
}
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
{
2+
"description": "retryable abortTransaction on handshake errors",
3+
"schemaVersion": "1.4",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "4.2",
7+
"topologies": [
8+
"replicaset",
9+
"sharded",
10+
"load-balanced"
11+
],
12+
"serverless": "forbid",
13+
"auth": true
14+
}
15+
],
16+
"createEntities": [
17+
{
18+
"client": {
19+
"id": "client0",
20+
"useMultipleMongoses": false,
21+
"observeEvents": [
22+
"commandStartedEvent",
23+
"connectionCheckOutStartedEvent"
24+
]
25+
}
26+
},
27+
{
28+
"database": {
29+
"id": "database0",
30+
"client": "client0",
31+
"databaseName": "retryable-handshake-tests"
32+
}
33+
},
34+
{
35+
"collection": {
36+
"id": "collection0",
37+
"database": "database0",
38+
"collectionName": "coll"
39+
}
40+
},
41+
{
42+
"session": {
43+
"id": "session0",
44+
"client": "client0"
45+
}
46+
},
47+
{
48+
"session": {
49+
"id": "session1",
50+
"client": "client0"
51+
}
52+
}
53+
],
54+
"initialData": [
55+
{
56+
"collectionName": "coll",
57+
"databaseName": "retryable-handshake-tests",
58+
"documents": [
59+
{
60+
"_id": 1,
61+
"x": 11
62+
}
63+
]
64+
}
65+
],
66+
"tests": [
67+
{
68+
"description": "AbortTransaction succeeds after handshake network error",
69+
"skipReason": "DRIVERS-2032: Pinned servers need to be checked if they are still selectable",
70+
"operations": [
71+
{
72+
"name": "startTransaction",
73+
"object": "session0"
74+
},
75+
{
76+
"name": "insertOne",
77+
"object": "collection0",
78+
"arguments": {
79+
"session": "session0",
80+
"document": {
81+
"_id": 2,
82+
"x": 22
83+
}
84+
}
85+
},
86+
{
87+
"name": "failPoint",
88+
"object": "testRunner",
89+
"arguments": {
90+
"client": "client0",
91+
"session": "session1",
92+
"failPoint": {
93+
"configureFailPoint": "failCommand",
94+
"mode": {
95+
"times": 2
96+
},
97+
"data": {
98+
"failCommands": [
99+
"saslContinue",
100+
"ping"
101+
],
102+
"closeConnection": true
103+
}
104+
}
105+
}
106+
},
107+
{
108+
"name": "runCommand",
109+
"object": "database0",
110+
"arguments": {
111+
"commandName": "ping",
112+
"command": {
113+
"ping": 1
114+
},
115+
"session": "session1"
116+
},
117+
"expectError": {
118+
"isError": true
119+
}
120+
},
121+
{
122+
"name": "abortTransaction",
123+
"object": "session0"
124+
}
125+
],
126+
"expectEvents": [
127+
{
128+
"client": "client0",
129+
"eventType": "cmap",
130+
"events": [
131+
{
132+
"connectionCheckOutStartedEvent": {}
133+
},
134+
{
135+
"connectionCheckOutStartedEvent": {}
136+
},
137+
{
138+
"connectionCheckOutStartedEvent": {}
139+
},
140+
{
141+
"connectionCheckOutStartedEvent": {}
142+
},
143+
{
144+
"connectionCheckOutStartedEvent": {}
145+
}
146+
]
147+
},
148+
{
149+
"client": "client0",
150+
"events": [
151+
{
152+
"commandStartedEvent": {
153+
"command": {
154+
"insert": "coll",
155+
"documents": [
156+
{
157+
"_id": 2,
158+
"x": 22
159+
}
160+
],
161+
"startTransaction": true
162+
},
163+
"commandName": "insert",
164+
"databaseName": "retryable-handshake-tests"
165+
}
166+
},
167+
{
168+
"commandStartedEvent": {
169+
"command": {
170+
"ping": 1
171+
},
172+
"databaseName": "retryable-handshake-tests"
173+
}
174+
},
175+
{
176+
"commandStartedEvent": {
177+
"command": {
178+
"abortTransaction": 1,
179+
"lsid": {
180+
"$$sessionLsid": "session0"
181+
}
182+
},
183+
"commandName": "abortTransaction",
184+
"databaseName": "admin"
185+
}
186+
}
187+
]
188+
}
189+
],
190+
"outcome": [
191+
{
192+
"collectionName": "coll",
193+
"databaseName": "retryable-handshake-tests",
194+
"documents": [
195+
{
196+
"_id": 1,
197+
"x": 11
198+
}
199+
]
200+
}
201+
]
202+
}
203+
]
204+
}

0 commit comments

Comments
 (0)