From d9b5ba2d1710d7f52536ab9c53c3a68329f61b90 Mon Sep 17 00:00:00 2001 From: Tess Avitabile Date: Tue, 4 Sep 2018 11:50:10 -0400 Subject: SERVER-36975 Fix race condition in read_concern_snapshot_catalog_invalidation.js --- .../noPassthrough/read_concern_snapshot_catalog_invalidation.js | 9 ++++++++- src/mongo/db/SConscript | 1 + src/mongo/db/transaction_participant.cpp | 6 +++++- 3 files changed, 14 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/SConscript b/src/mongo/db/SConscript index d327b38f363..7e83900541d 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -643,6 +643,7 @@ env.Library( 'catalog/database_holder', 'catalog/uuid_catalog', 'concurrency/lock_manager', + 'curop_failpoint_helpers', 'curop_metrics', 'dbdirectclient', 'index/index_access_method', 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) { -- cgit v1.2.1