| 1 |
runOn: |
| 2 |
- |
| 3 |
minServerVersion: "4.0" |
| 4 |
topology: ["replicaset"] |
| 5 |
- |
| 6 |
minServerVersion: "4.1.8" |
| 7 |
topology: ["sharded"] |
| 8 |
|
| 9 |
database_name: &database_name "withTransaction-tests" |
| 10 |
collection_name: &collection_name "test" |
| 11 |
|
| 12 |
data: [] |
| 13 |
|
| 14 |
tests: |
| 15 |
- |
| 16 |
description: commitTransaction succeeds after multiple connection errors |
| 17 |
failPoint: |
| 18 |
configureFailPoint: failCommand |
| 19 |
mode: { times: 2 } |
| 20 |
data: |
| 21 |
failCommands: ["commitTransaction"] |
| 22 |
closeConnection: true |
| 23 |
operations: |
| 24 |
- &withTransaction |
| 25 |
name: withTransaction |
| 26 |
object: session0 |
| 27 |
arguments: |
| 28 |
callback: |
| 29 |
operations: |
| 30 |
- |
| 31 |
name: insertOne |
| 32 |
object: collection |
| 33 |
arguments: |
| 34 |
session: session0 |
| 35 |
document: { _id: 1 } |
| 36 |
result: |
| 37 |
insertedId: 1 |
| 38 |
expectations: |
| 39 |
- |
| 40 |
command_started_event: |
| 41 |
command: |
| 42 |
insert: *collection_name |
| 43 |
documents: |
| 44 |
- { _id: 1 } |
| 45 |
ordered: true |
| 46 |
lsid: session0 |
| 47 |
txnNumber: { $numberLong: "1" } |
| 48 |
startTransaction: true |
| 49 |
autocommit: false |
| 50 |
# omitted fields |
| 51 |
readConcern: ~ |
| 52 |
writeConcern: ~ |
| 53 |
command_name: insert |
| 54 |
database_name: *database_name |
| 55 |
- |
| 56 |
command_started_event: |
| 57 |
command: |
| 58 |
commitTransaction: 1 |
| 59 |
lsid: session0 |
| 60 |
txnNumber: { $numberLong: "1" } |
| 61 |
autocommit: false |
| 62 |
# omitted fields |
| 63 |
readConcern: ~ |
| 64 |
startTransaction: ~ |
| 65 |
writeConcern: ~ |
| 66 |
command_name: commitTransaction |
| 67 |
database_name: admin |
| 68 |
- |
| 69 |
command_started_event: |
| 70 |
command: |
| 71 |
commitTransaction: 1 |
| 72 |
lsid: session0 |
| 73 |
txnNumber: { $numberLong: "1" } |
| 74 |
autocommit: false |
| 75 |
# commitTransaction applies w:majority on retries (SPEC-1185) |
| 76 |
writeConcern: { w: majority, wtimeout: 10000 } |
| 77 |
# omitted fields |
| 78 |
readConcern: ~ |
| 79 |
startTransaction: ~ |
| 80 |
command_name: commitTransaction |
| 81 |
database_name: admin |
| 82 |
- |
| 83 |
command_started_event: |
| 84 |
command: |
| 85 |
commitTransaction: 1 |
| 86 |
lsid: session0 |
| 87 |
txnNumber: { $numberLong: "1" } |
| 88 |
autocommit: false |
| 89 |
# commitTransaction applies w:majority on retries (SPEC-1185) |
| 90 |
writeConcern: { w: majority, wtimeout: 10000 } |
| 91 |
# omitted fields |
| 92 |
readConcern: ~ |
| 93 |
startTransaction: ~ |
| 94 |
command_name: commitTransaction |
| 95 |
database_name: admin |
| 96 |
outcome: |
| 97 |
collection: |
| 98 |
data: |
| 99 |
- { _id: 1 } |
| 100 |
- |
| 101 |
description: commitTransaction retry only overwrites write concern w option |
| 102 |
failPoint: |
| 103 |
configureFailPoint: failCommand |
| 104 |
mode: { times: 2 } |
| 105 |
data: |
| 106 |
failCommands: ["commitTransaction"] |
| 107 |
closeConnection: true |
| 108 |
operations: |
| 109 |
- |
| 110 |
name: withTransaction |
| 111 |
object: session0 |
| 112 |
arguments: |
| 113 |
callback: |
| 114 |
operations: |
| 115 |
- |
| 116 |
name: insertOne |
| 117 |
object: collection |
| 118 |
arguments: |
| 119 |
session: session0 |
| 120 |
document: { _id: 1 } |
| 121 |
result: |
| 122 |
insertedId: 1 |
| 123 |
options: |
| 124 |
writeConcern: { w: 2, j: true, wtimeout: 5000 } |
| 125 |
expectations: |
| 126 |
- |
| 127 |
command_started_event: |
| 128 |
command: |
| 129 |
insert: *collection_name |
| 130 |
documents: |
| 131 |
- { _id: 1 } |
| 132 |
ordered: true |
| 133 |
lsid: session0 |
| 134 |
txnNumber: { $numberLong: "1" } |
| 135 |
startTransaction: true |
| 136 |
autocommit: false |
| 137 |
# omitted fields |
| 138 |
readConcern: ~ |
| 139 |
writeConcern: ~ |
| 140 |
command_name: insert |
| 141 |
database_name: *database_name |
| 142 |
- |
| 143 |
command_started_event: |
| 144 |
command: |
| 145 |
commitTransaction: 1 |
| 146 |
lsid: session0 |
| 147 |
txnNumber: { $numberLong: "1" } |
| 148 |
autocommit: false |
| 149 |
writeConcern: { w: 2, j: true, wtimeout: 5000 } |
| 150 |
# omitted fields |
| 151 |
readConcern: ~ |
| 152 |
startTransaction: ~ |
| 153 |
command_name: commitTransaction |
| 154 |
database_name: admin |
| 155 |
- |
| 156 |
command_started_event: |
| 157 |
command: |
| 158 |
commitTransaction: 1 |
| 159 |
lsid: session0 |
| 160 |
txnNumber: { $numberLong: "1" } |
| 161 |
autocommit: false |
| 162 |
# commitTransaction applies w:majority on retries (SPEC-1185) |
| 163 |
writeConcern: { w: majority, j: true, wtimeout: 5000 } |
| 164 |
# omitted fields |
| 165 |
readConcern: ~ |
| 166 |
startTransaction: ~ |
| 167 |
command_name: commitTransaction |
| 168 |
database_name: admin |
| 169 |
- |
| 170 |
command_started_event: |
| 171 |
command: |
| 172 |
commitTransaction: 1 |
| 173 |
lsid: session0 |
| 174 |
txnNumber: { $numberLong: "1" } |
| 175 |
autocommit: false |
| 176 |
# commitTransaction applies w:majority on retries (SPEC-1185) |
| 177 |
writeConcern: { w: majority, j: true, wtimeout: 5000 } |
| 178 |
# omitted fields |
| 179 |
readConcern: ~ |
| 180 |
startTransaction: ~ |
| 181 |
command_name: commitTransaction |
| 182 |
database_name: admin |
| 183 |
outcome: |
| 184 |
collection: |
| 185 |
data: |
| 186 |
- { _id: 1 } |
| 187 |
- |
| 188 |
description: commit is retried after commitTransaction UnknownTransactionCommitResult (NotWritablePrimary) |
| 189 |
failPoint: |
| 190 |
configureFailPoint: failCommand |
| 191 |
mode: { times: 2 } |
| 192 |
data: |
| 193 |
failCommands: ["commitTransaction"] |
| 194 |
errorCode: 10107 # NotWritablePrimary |
| 195 |
errorLabels: ["RetryableWriteError"] # SPEC-1565 |
| 196 |
closeConnection: false |
| 197 |
operations: |
| 198 |
- *withTransaction |
| 199 |
expectations: |
| 200 |
- |
| 201 |
command_started_event: |
| 202 |
command: |
| 203 |
insert: *collection_name |
| 204 |
documents: |
| 205 |
- { _id: 1 } |
| 206 |
ordered: true |
| 207 |
lsid: session0 |
| 208 |
txnNumber: { $numberLong: "1" } |
| 209 |
startTransaction: true |
| 210 |
autocommit: false |
| 211 |
# omitted fields |
| 212 |
readConcern: ~ |
| 213 |
writeConcern: ~ |
| 214 |
command_name: insert |
| 215 |
database_name: *database_name |
| 216 |
- |
| 217 |
command_started_event: |
| 218 |
command: |
| 219 |
commitTransaction: 1 |
| 220 |
lsid: session0 |
| 221 |
txnNumber: { $numberLong: "1" } |
| 222 |
autocommit: false |
| 223 |
# omitted fields |
| 224 |
readConcern: ~ |
| 225 |
startTransaction: ~ |
| 226 |
writeConcern: ~ |
| 227 |
command_name: commitTransaction |
| 228 |
database_name: admin |
| 229 |
- |
| 230 |
command_started_event: |
| 231 |
command: |
| 232 |
commitTransaction: 1 |
| 233 |
lsid: session0 |
| 234 |
txnNumber: { $numberLong: "1" } |
| 235 |
autocommit: false |
| 236 |
# commitTransaction applies w:majority on retries (SPEC-1185) |
| 237 |
writeConcern: { w: majority, wtimeout: 10000 } |
| 238 |
# omitted fields |
| 239 |
readConcern: ~ |
| 240 |
startTransaction: ~ |
| 241 |
command_name: commitTransaction |
| 242 |
database_name: admin |
| 243 |
- |
| 244 |
command_started_event: |
| 245 |
command: |
| 246 |
commitTransaction: 1 |
| 247 |
lsid: session0 |
| 248 |
txnNumber: { $numberLong: "1" } |
| 249 |
autocommit: false |
| 250 |
# commitTransaction applies w:majority on retries (SPEC-1185) |
| 251 |
writeConcern: { w: majority, wtimeout: 10000 } |
| 252 |
# omitted fields |
| 253 |
readConcern: ~ |
| 254 |
startTransaction: ~ |
| 255 |
command_name: commitTransaction |
| 256 |
database_name: admin |
| 257 |
outcome: |
| 258 |
collection: |
| 259 |
data: |
| 260 |
- { _id: 1 } |
| 261 |
- |
| 262 |
description: commit is not retried after MaxTimeMSExpired error |
| 263 |
failPoint: |
| 264 |
configureFailPoint: failCommand |
| 265 |
mode: { times: 1 } |
| 266 |
data: |
| 267 |
failCommands: ["commitTransaction"] |
| 268 |
errorCode: 50 # MaxTimeMSExpired |
| 269 |
operations: |
| 270 |
- name: withTransaction |
| 271 |
object: session0 |
| 272 |
arguments: |
| 273 |
callback: |
| 274 |
operations: |
| 275 |
- |
| 276 |
name: insertOne |
| 277 |
object: collection |
| 278 |
arguments: |
| 279 |
session: session0 |
| 280 |
document: { _id: 1 } |
| 281 |
result: |
| 282 |
insertedId: 1 |
| 283 |
options: |
| 284 |
maxCommitTimeMS: 60000 |
| 285 |
result: |
| 286 |
errorCodeName: MaxTimeMSExpired |
| 287 |
errorLabelsContain: ["UnknownTransactionCommitResult"] |
| 288 |
errorLabelsOmit: ["TransientTransactionError"] |
| 289 |
expectations: |
| 290 |
- |
| 291 |
command_started_event: |
| 292 |
command: |
| 293 |
insert: *collection_name |
| 294 |
documents: |
| 295 |
- { _id: 1 } |
| 296 |
ordered: true |
| 297 |
lsid: session0 |
| 298 |
txnNumber: { $numberLong: "1" } |
| 299 |
startTransaction: true |
| 300 |
autocommit: false |
| 301 |
# omitted fields |
| 302 |
readConcern: ~ |
| 303 |
writeConcern: ~ |
| 304 |
command_name: insert |
| 305 |
database_name: *database_name |
| 306 |
- |
| 307 |
command_started_event: |
| 308 |
command: |
| 309 |
commitTransaction: 1 |
| 310 |
lsid: session0 |
| 311 |
txnNumber: { $numberLong: "1" } |
| 312 |
autocommit: false |
| 313 |
maxTimeMS: 60000 |
| 314 |
# omitted fields |
| 315 |
readConcern: ~ |
| 316 |
startTransaction: ~ |
| 317 |
writeConcern: ~ |
| 318 |
command_name: commitTransaction |
| 319 |
database_name: admin |
| 320 |
outcome: |
| 321 |
collection: |
| 322 |
# In reality, the outcome of the commit is unknown but we fabricate |
| 323 |
# the error with failCommand.errorCode which does not apply the commit |
| 324 |
# operation. |
| 325 |
data: [] |