diff options
author | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-12-18 18:04:09 -0500 |
---|---|---|
committer | Jack Mulrow <jack.mulrow@mongodb.com> | 2018-12-19 11:08:28 -0500 |
commit | 14e2a9697475191807f8ece0843876109ec25d5d (patch) | |
tree | d7c49006caa13e95f19eb092422507af5bcb80cd /jstests/concurrency | |
parent | 8df4497cfc7403a9063b79ed97c3e3e489ea35e3 (diff) | |
download | mongo-14e2a9697475191807f8ece0843876109ec25d5d.tar.gz |
SERVER-38628 Concurrency txn passthroughs shouldn't modify thread local state until after commit
Diffstat (limited to 'jstests/concurrency')
-rw-r--r-- | jstests/concurrency/fsm_libs/fsm.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/jstests/concurrency/fsm_libs/fsm.js b/jstests/concurrency/fsm_libs/fsm.js index acfc869dd2d..49be6ac98b3 100644 --- a/jstests/concurrency/fsm_libs/fsm.js +++ b/jstests/concurrency/fsm_libs/fsm.js @@ -52,14 +52,15 @@ var fsm = (function() { if (TestData.runInsideTransaction) { try { + // We make a deep copy of 'args.data' before running the state function in a + // transaction so that if the transaction aborts, then we haven't speculatively + // modified the thread-local state. + let data; withTxnAndAutoRetry(args.db.getSession(), () => { - // We make a deep copy of 'args.data' before calling the 'fn' state function - // so that if the transaction aborts, then we haven't speculatively modified - // the thread-local state. - const data = deepCopyObject({}, args.data); + data = deepCopyObject({}, args.data); fn.call(data, args.db, args.collName, connCache); - args.data = data; }); + args.data = data; } catch (e) { // Retry state functions that threw OperationNotSupportedInTransaction or // InvalidOptions errors outside of a transaction. Rethrow any other error. |