diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-03-03 10:46:39 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-13 17:21:07 +0000 |
commit | c15e8ae74071482d69179c7e5e5e6bdc882d2beb (patch) | |
tree | a17f28ebb0e53c69f2b1c07f6e4d41dedf78f5fe /jstests | |
parent | 46b4b3d8f03e3dfc3ca2ae344bf7848732e986c3 (diff) | |
download | mongo-c15e8ae74071482d69179c7e5e5e6bdc882d2beb.tar.gz |
SERVER-45626: Introduce AutoGetOplog for consistent oplog locking rules
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/transient_txn_error_labels_with_write_concern.js | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/jstests/sharding/transient_txn_error_labels_with_write_concern.js b/jstests/sharding/transient_txn_error_labels_with_write_concern.js index 3639ce618e4..d7a6f7f2184 100644 --- a/jstests/sharding/transient_txn_error_labels_with_write_concern.js +++ b/jstests/sharding/transient_txn_error_labels_with_write_concern.js @@ -1,12 +1,13 @@ /** * Test TransientTransactionError error label for commands in transactions with write concern. * @tags: [ - * uses_transactions + * uses_transactions, requires_fcv_44 * ] */ (function() { "use strict"; +load("jstests/libs/fail_point_util.js"); load("jstests/libs/write_concern_util.js"); load("jstests/replsets/rslib.js"); @@ -81,34 +82,10 @@ function runNoSuchTransactionTests(cmd, cmdName) { jsTest.log("If the noop write for NoSuchTransaction cannot occur, the error is not transient"); - // Lock 'local' database in X mode. - let lockShell = startParallelShell(function() { - assert.commandFailed(db.adminCommand({ - sleep: 1, - secs: 500, - lock: "w", - lockTarget: "local", - $comment: "transient_txn_error_labels_with_write_concern lock sleep" - })); - }, rst.ports[0]); - - // Wait for sleep to appear in currentOp - let opId = -1; - assert.soon(function() { - const curopRes = testDB.currentOp(); - assert.commandWorked(curopRes); - const foundOp = curopRes["inprog"].filter( - op => (op["ns"] == "admin.$cmd" && - op["command"]["$comment"] == - "transient_txn_error_labels_with_write_concern lock sleep")); - if (foundOp.length == 1) { - opId = foundOp[0]["opid"]; - } - return (foundOp.length == 1); - }); + const failpoint = configureFailPoint(primary, "failTransactionNoopWrite"); // The server will attempt to perform a noop write, since the command returns - // NoSuchTransaction. The noop write will time out acquiring a lock on the 'local' database. + // NoSuchTransaction. The noop write will time out because of the failpoint. // This should not be a TransientTransactionError, since the server has not successfully // replicated a write to confirm that it is primary. // Use a txnNumber that is one higher than the server has tracked. @@ -118,12 +95,12 @@ function runNoSuchTransactionTests(cmd, cmdName) { writeConcern: writeConcernMajority, maxTimeMS: 1000 })); + + failpoint.off(); + assert.commandFailedWithCode(res, ErrorCodes.MaxTimeMSExpired); assert(!res.hasOwnProperty("errorLabels")); - assert.commandWorked(testDB.killOp(opId)); - lockShell(); - rst.awaitReplication(); } |