diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-09-28 14:12:16 -0400 |
---|---|---|
committer | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-10-09 09:39:08 -0400 |
commit | d2d7dbadcc008a484218321666aae44b75964787 (patch) | |
tree | 6d5167a57fd3d446144d8dc08f078dfbbfbd52f6 /jstests/sharding/transactions_stale_database_version_errors.js | |
parent | 1e03955cdab995fed6672d75a6a4544a9771a279 (diff) | |
download | mongo-d2d7dbadcc008a484218321666aae44b75964787.tar.gz |
SERVER-37210 Mongos should implicitly abort transactions on unhandled errors
Diffstat (limited to 'jstests/sharding/transactions_stale_database_version_errors.js')
-rw-r--r-- | jstests/sharding/transactions_stale_database_version_errors.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/jstests/sharding/transactions_stale_database_version_errors.js b/jstests/sharding/transactions_stale_database_version_errors.js index 6c3329c5400..a4a2db4d294 100644 --- a/jstests/sharding/transactions_stale_database_version_errors.js +++ b/jstests/sharding/transactions_stale_database_version_errors.js @@ -4,6 +4,8 @@ (function() { "use strict"; + load("jstests/sharding/libs/sharded_transactions_helpers.js"); + const dbName = "test"; const collName = "foo"; @@ -50,7 +52,10 @@ ErrorCodes.NoSuchTransaction); assert.eq(res.errorLabels, ["TransientTransactionError"]); - session.abortTransaction(); + assertNoSuchTransactionOnAllShards( + st, session.getSessionId(), session.getTxnNumber_forTesting()); + assert.commandFailedWithCode(session.abortTransaction_forTesting(), + ErrorCodes.NoSuchTransaction); // // Stale database version on first command to a new shard should succeed. @@ -91,6 +96,7 @@ // st.ensurePrimaryShard(dbName, st.shard0.shardName); + st.ensurePrimaryShard(otherDbName, st.shard1.shardName); // Disable database metadata refreshes on the stale shard so it will indefinitely return a stale // version error. @@ -99,13 +105,20 @@ session.startTransaction(); + // Target Shard1, to verify the transaction on it is implicitly aborted later. + assert.commandWorked(sessionOtherDB.runCommand({find: otherCollName})); + // Target the first database which is on Shard0. The shard is stale and won't refresh its // metadata, so mongos should exhaust its retries and implicitly abort the transaction. assert.commandFailedWithCode( sessionDB.runCommand({distinct: collName, key: "_id", query: {_id: 0}}), ErrorCodes.NoSuchTransaction); - session.abortTransaction(); + // Verify all shards aborted the transaction. + assertNoSuchTransactionOnAllShards( + st, session.getSessionId(), session.getTxnNumber_forTesting()); + assert.commandFailedWithCode(session.abortTransaction_forTesting(), + ErrorCodes.NoSuchTransaction); assert.commandWorked(st.rs0.getPrimary().adminCommand( {configureFailPoint: "skipDatabaseVersionMetadataRefresh", mode: "off"})); |