diff options
author | Randolph Tan <randolph@10gen.com> | 2018-12-12 17:58:38 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2019-02-28 17:33:31 -0500 |
commit | c5f474e0728ab6cd75e23ce9f343cc20ac3c1f14 (patch) | |
tree | 586ef9a1da73625f4ac817900bd2abca647e0a9c /src | |
parent | 78d82f7dab0efcf651535665703ae1f80e759605 (diff) | |
download | mongo-c5f474e0728ab6cd75e23ce9f343cc20ac3c1f14.tar.gz |
SERVER-37972 Create suite for running multi shard jscore with sharded transactions with kill
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/transaction_coordinator.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/s/transaction_coordinator_catalog.cpp | 3 | ||||
-rw-r--r-- | src/mongo/s/transaction_router.cpp | 19 |
3 files changed, 23 insertions, 10 deletions
diff --git a/src/mongo/db/s/transaction_coordinator.cpp b/src/mongo/db/s/transaction_coordinator.cpp index 5a1d0dfd41c..6be5d1bf69a 100644 --- a/src/mongo/db/s/transaction_coordinator.cpp +++ b/src/mongo/db/s/transaction_coordinator.cpp @@ -36,6 +36,7 @@ #include "mongo/db/logical_clock.h" #include "mongo/db/s/transaction_coordinator_document_gen.h" #include "mongo/db/s/transaction_coordinator_futures_util.h" +#include "mongo/util/fail_point_service.h" #include "mongo/util/log.h" namespace mongo { @@ -205,7 +206,15 @@ Future<CoordinatorCommitDecision> TransactionCoordinator::_runPhaseOne( Future<void> TransactionCoordinator::_runPhaseTwo(const std::vector<ShardId>& participantShards, const CoordinatorCommitDecision& decision) { return _sendDecisionToParticipants(participantShards, decision) - .then([this] { return _driver.deleteCoordinatorDoc(_lsid, _txnNumber); }) + .then([this] { + if (getGlobalFailPointRegistry() + ->getFailPoint("doNotForgetCoordinator") + ->shouldFail()) { + return Future<void>::makeReady(); + } + + return _driver.deleteCoordinatorDoc(_lsid, _txnNumber); + }) .then([this] { LOG(3) << "Two-phase commit completed for session " << _lsid.toBSON() << ", transaction number " << _txnNumber; diff --git a/src/mongo/db/s/transaction_coordinator_catalog.cpp b/src/mongo/db/s/transaction_coordinator_catalog.cpp index 3fa862ddde3..38e6f95cb30 100644 --- a/src/mongo/db/s/transaction_coordinator_catalog.cpp +++ b/src/mongo/db/s/transaction_coordinator_catalog.cpp @@ -186,7 +186,6 @@ void TransactionCoordinatorCatalog::_remove(const LogicalSessionId& lsid, TxnNum if (MONGO_FAIL_POINT(doNotForgetCoordinator)) { auto decisionFuture = coordinator->getDecision(); - invariant(decisionFuture.isReady()); // Only remember a coordinator that completed successfully. We expect that the // coordinator only completes with an error if the node stepped down or was shut // down while coordinating the commit. If either of these occurred, a @@ -195,7 +194,7 @@ void TransactionCoordinatorCatalog::_remove(const LogicalSessionId& lsid, TxnNum // shutdown), or should find no coordinator and instead recover the decision from // the local participant (if the failover or shutdown occurred before any of the // coordinator's state was made durable). - if (decisionFuture.getNoThrow().isOK()) { + if (decisionFuture.isReady() && decisionFuture.getNoThrow().isOK()) { _coordinatorsBySessionDefunct[lsid][txnNumber] = std::move(coordinator); } } diff --git a/src/mongo/s/transaction_router.cpp b/src/mongo/s/transaction_router.cpp index 0975508bfa9..51ca27d08b1 100644 --- a/src/mongo/s/transaction_router.cpp +++ b/src/mongo/s/transaction_router.cpp @@ -613,17 +613,23 @@ Shard::CommandResponse TransactionRouter::_commitMultiShardTransaction(Operation coordinatorShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); if (!_initiatedTwoPhaseCommit) { + SharedTransactionOptions options; + options.txnNumber = _txnNumber; + // Intentionally leave atClusterTime blank since we don't care and to minimize + // possibility that storage engine won't have it available. + Participant configParticipant(true, 0, options); + // Send a fake transaction statement to the config server primary so that the config // server primary sets up state in memory to receive coordinateCommit. auto cmdResponse = coordinatorShard->runCommandWithFixedRetryAttempts( opCtx, ReadPreferenceSetting{ReadPreference::PrimaryOnly}, "dummy", - coordinatorIter->second.attachTxnFieldsIfNeeded(BSON("distinct" - << "dummy" - << "key" - << "dummy"), - true), + configParticipant.attachTxnFieldsIfNeeded(BSON("distinct" + << "dummy" + << "key" + << "dummy"), + true), Shard::RetryPolicy::kIdempotent); uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(cmdResponse)); @@ -633,8 +639,7 @@ Shard::CommandResponse TransactionRouter::_commitMultiShardTransaction(Operation opCtx, ReadPreferenceSetting{ReadPreference::PrimaryOnly}, "admin", - coordinatorIter->second.attachTxnFieldsIfNeeded(BSON("abortTransaction" << 1), - false), + configParticipant.attachTxnFieldsIfNeeded(BSON("abortTransaction" << 1), false), Shard::RetryPolicy::kIdempotent); uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(cmdResponse)); } |