summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2018-09-04 11:50:10 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2018-09-05 11:20:19 -0400
commitbd982824a7967b5e518bf9255b8f5e051bdaff7d (patch)
treeb229a6707b7dba1d5df2a82db1423431554c4d29
parentfac4037c57431e3318e04cc850b9ea391ff5f19c (diff)
downloadmongo-bd982824a7967b5e518bf9255b8f5e051bdaff7d.tar.gz
SERVER-36975 Fix race condition in read_concern_snapshot_catalog_invalidation.js
-rw-r--r--jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js9
-rw-r--r--src/mongo/db/transaction_participant.cpp6
2 files changed, 13 insertions, 2 deletions
diff --git a/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js b/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js
index ad8ce3a6337..eefbe613f84 100644
--- a/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js
+++ b/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js
@@ -15,10 +15,17 @@
const adminDB = testDB.getSiblingDB("admin");
const coll = testDB.getCollection(kCollName);
+ // Waits for the operation to reach the "hangAfterPreallocateSnapshot" failpoint.
function waitForOp(curOpFilter) {
assert.soon(
function() {
- const res = adminDB.aggregate([{$currentOp: {}}, {$match: curOpFilter}]).toArray();
+ const res =
+ adminDB
+ .aggregate([
+ {$currentOp: {}},
+ {$match: {$and: [curOpFilter, {msg: "hangAfterPreallocateSnapshot"}]}}
+ ])
+ .toArray();
if (res.length === 1) {
return true;
}
diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp
index ba01744fff4..b84088757a7 100644
--- a/src/mongo/db/transaction_participant.cpp
+++ b/src/mongo/db/transaction_participant.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/concurrency/locker.h"
+#include "mongo/db/curop_failpoint_helpers.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/server_parameters.h"
@@ -515,7 +516,10 @@ void TransactionParticipant::unstashTransactionResources(OperationContext* opCtx
// The Client lock must not be held when executing this failpoint as it will block currentOp
// execution.
- MONGO_FAIL_POINT_PAUSE_WHILE_SET(hangAfterPreallocateSnapshot);
+ if (MONGO_FAIL_POINT(hangAfterPreallocateSnapshot)) {
+ CurOpFailpointHelpers::waitWhileFailPointEnabled(
+ &hangAfterPreallocateSnapshot, opCtx, "hangAfterPreallocateSnapshot");
+ }
}
Timestamp TransactionParticipant::prepareTransaction(OperationContext* opCtx) {