Skip to content

Commit c5d1c77

Browse files
authored
DRIVERS-2395: Add test that read is not retried in a transaction (#1277)
1 parent 8d897ad commit c5d1c77

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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+
"single",
9+
"replicaset"
10+
]
11+
},
12+
{
13+
"minServerVersion": "4.2.0",
14+
"topologies": [
15+
"sharded",
16+
"load-balanced"
17+
]
18+
}
19+
],
20+
"createEntities": [
21+
{
22+
"client": {
23+
"id": "client0",
24+
"useMultipleMongoses": false,
25+
"observeEvents": [
26+
"commandStartedEvent"
27+
],
28+
"uriOptions": {
29+
"retryReads": true
30+
}
31+
}
32+
},
33+
{
34+
"database": {
35+
"id": "database0",
36+
"client": "client0",
37+
"databaseName": "retryable-read-in-transaction-test"
38+
}
39+
},
40+
{
41+
"collection": {
42+
"id": "collection0",
43+
"database": "database0",
44+
"collectionName": "coll"
45+
}
46+
},
47+
{
48+
"session": {
49+
"id": "session0",
50+
"client": "client0"
51+
}
52+
}
53+
],
54+
"tests": [
55+
{
56+
"description": "find does not retry in a transaction",
57+
"operations": [
58+
{
59+
"name": "startTransaction",
60+
"object": "session0"
61+
},
62+
{
63+
"name": "failPoint",
64+
"object": "testRunner",
65+
"arguments": {
66+
"client": "client0",
67+
"failPoint": {
68+
"configureFailPoint": "failCommand",
69+
"mode": {
70+
"times": 1
71+
},
72+
"data": {
73+
"failCommands": [
74+
"find"
75+
],
76+
"closeConnection": true
77+
}
78+
}
79+
}
80+
},
81+
{
82+
"name": "find",
83+
"object": "collection0",
84+
"arguments": {
85+
"filter": {},
86+
"session": "session0"
87+
},
88+
"expectError": {
89+
"isError": true,
90+
"errorLabelsContain": [
91+
"TransientTransactionError"
92+
]
93+
}
94+
}
95+
],
96+
"expectEvents": [
97+
{
98+
"client": "client0",
99+
"events": [
100+
{
101+
"commandStartedEvent": {
102+
"command": {
103+
"find": "coll",
104+
"filter": {},
105+
"startTransaction": true
106+
},
107+
"commandName": "find",
108+
"databaseName": "retryable-read-in-transaction-test"
109+
}
110+
}
111+
]
112+
}
113+
]
114+
}
115+
]
116+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
description: "do not retry read in a transaction"
2+
3+
schemaVersion: "1.4"
4+
5+
runOnRequirements:
6+
- minServerVersion: "4.0.0"
7+
topologies: [ single, replicaset ]
8+
- minServerVersion: "4.2.0"
9+
topologies: [ sharded, load-balanced ]
10+
11+
createEntities:
12+
- client:
13+
id: &client0 client0
14+
useMultipleMongoses: false
15+
observeEvents: [commandStartedEvent]
16+
uriOptions: { retryReads: true }
17+
- database:
18+
id: &database0 database0
19+
client: *client0
20+
databaseName: &databaseName retryable-read-in-transaction-test
21+
- collection:
22+
id: &collection0 collection0
23+
database: *database0
24+
collectionName: &collectionName coll
25+
- session:
26+
id: &session0 session0
27+
client: *client0
28+
29+
tests:
30+
- description: "find does not retry in a transaction"
31+
operations:
32+
33+
- name: startTransaction
34+
object: *session0
35+
36+
- name: failPoint # fail the following find command
37+
object: testRunner
38+
arguments:
39+
client: *client0
40+
failPoint:
41+
configureFailPoint: failCommand
42+
mode: { times: 1 }
43+
data:
44+
failCommands: [find]
45+
closeConnection: true
46+
47+
- name: find
48+
object: *collection0
49+
arguments:
50+
filter: {}
51+
session: *session0
52+
expectError:
53+
isError: true
54+
errorLabelsContain: ["TransientTransactionError"]
55+
expectEvents:
56+
- client: *client0
57+
events:
58+
- commandStartedEvent:
59+
command:
60+
find: *collectionName
61+
filter: {}
62+
startTransaction: true
63+
commandName: find
64+
databaseName: *databaseName

0 commit comments

Comments
 (0)