diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2018-06-26 11:07:51 -0400 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2018-06-26 11:54:01 -0400 |
commit | 7795f9ac84cbb2af05f1e058d0e6b1de05601b26 (patch) | |
tree | ad9351d86ee6206a4d4f515e77b3dbe7161632f2 | |
parent | 68953e42038305d6ed83f3614d43a7fd4fc897c9 (diff) | |
download | mongo-7795f9ac84cbb2af05f1e058d0e6b1de05601b26.tar.gz |
SERVER-35559 Correct logic in auto_retry_transaction.js
-rw-r--r-- | jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js b/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js index 229abb69cc4..6aa821966a3 100644 --- a/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js +++ b/jstests/concurrency/fsm_workload_helpers/auto_retry_transaction.js @@ -35,7 +35,7 @@ var {withTxnAndAutoRetry} = (function() { do { session.startTransaction(txnOptions); - let commitErrorSessionId = undefined; + let hasCommitTxnError = false; hasTransientError = false; try { @@ -46,16 +46,18 @@ var {withTxnAndAutoRetry} = (function() { try { quietly(() => session.commitTransaction()); } catch (e) { - commitErrorSessionId = session.getSessionId(); + hasCommitTxnError = true; throw e; } } catch (e) { - // Use the version of abortTransaction() that ignores errors. We ignore the error - // from abortTransaction because the transaction may have implicitly been aborted by - // the server already and will therefore return a NoSuchTransaction error response. - // We need to call abortTransaction() in order to update the mongo shell's state - // such that it agrees no transaction is currently in progress on this session. - if (session.getSessionId() !== commitErrorSessionId) { + if (!hasCommitTxnError) { + // Use the version of abortTransaction() that ignores errors. We ignore the + // error from abortTransaction because the transaction may have implicitly + // been aborted by the server already and will therefore return a + // NoSuchTransaction error response. + // We need to call abortTransaction() in order to update the mongo shell's + // state such that it agrees no transaction is currently in progress on this + // session. session.abortTransaction(); } |