summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosef Ahmad <josef.ahmad@mongodb.com>2021-11-17 15:56:47 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-07 08:11:38 +0000
commit79599d1ea413cfc331d8b48ac617dec08bdcba0f (patch)
treed9de902119072a5501cca7da3791b8495a8b9e44 /src
parenta1607ca021bcdd91f525e210a541741dfb9e337a (diff)
downloadmongo-79599d1ea413cfc331d8b48ac617dec08bdcba0f.tar.gz
SERVER-60682 Exempt transaction coordinators and journal flusher from acquiring storage tickets
Co-authored-by: Max Hirschhorn max.hirschhorn@mongodb.com (cherry picked from commit 1bdff76322b144ef27060fe79324fe3cce4bb17a)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/replication_consistency_markers_impl.cpp7
-rw-r--r--src/mongo/db/s/transaction_coordinator_util.cpp5
2 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_consistency_markers_impl.cpp b/src/mongo/db/repl/replication_consistency_markers_impl.cpp
index df8c3ebdd6d..e7151875651 100644
--- a/src/mongo/db/repl/replication_consistency_markers_impl.cpp
+++ b/src/mongo/db/repl/replication_consistency_markers_impl.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/catalog_raii.h"
#include "mongo/db/concurrency/d_concurrency.h"
+#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_coordinator.h"
@@ -498,6 +499,12 @@ ReplicationConsistencyMarkersImpl::refreshOplogTruncateAfterPointIfPrimary(
}
ON_BLOCK_EXIT([&] { opCtx->recoveryUnit()->setPrepareConflictBehavior(originalBehavior); });
+ // Exempt storage ticket acquisition in order to avoid starving upstream requests waiting
+ // for durability. SERVER-60682 is an example with more pending prepared transactions than
+ // storage tickets; the transaction coordinator could not persist the decision and
+ // had to unnecessarily wait for prepared transactions to expire to make forward progress.
+ SkipTicketAcquisitionForLock skipTicketAcquisition(opCtx);
+
// The locks necessary to write to the oplog truncate after point's collection and read from the
// oplog collection must be taken up front so that the mutex can also be taken around both
// operations without causing deadlocks.
diff --git a/src/mongo/db/s/transaction_coordinator_util.cpp b/src/mongo/db/s/transaction_coordinator_util.cpp
index 0bc0d019c6c..8fa377734ef 100644
--- a/src/mongo/db/s/transaction_coordinator_util.cpp
+++ b/src/mongo/db/s/transaction_coordinator_util.cpp
@@ -36,6 +36,7 @@
#include "mongo/client/remote_command_retry_scheduler.h"
#include "mongo/db/commands/txn_cmds_gen.h"
#include "mongo/db/commands/txn_two_phase_commit_cmds_gen.h"
+#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/curop.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/ops/write_ops.h"
@@ -411,6 +412,10 @@ Future<repl::OpTime> persistDecision(txn::AsyncWorkScheduler& scheduler,
return scheduler.scheduleWork(
[lsid, txnNumber, participants, decision](OperationContext* opCtx) {
FlowControl::Bypass flowControlBypass(opCtx);
+ // Do not acquire a storage ticket in order to avoid unnecessary serialization
+ // with other prepared transactions that are holding a storage ticket
+ // themselves; see SERVER-60682.
+ SkipTicketAcquisitionForLock skipTicketAcquisition(opCtx);
getTransactionCoordinatorWorkerCurOpRepository()->set(
opCtx, lsid, txnNumber, CoordinatorAction::kWritingDecision);
return persistDecisionBlocking(opCtx, lsid, txnNumber, participants, decision);