mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-50365 Use short WT transaction rollback timeout in the multi-document transaction expirer thread
This commit is contained in:
parent
30e0f2a2b3
commit
6b3e341703
@ -102,6 +102,11 @@ void PeriodicThreadToAbortExpiredTransactions::_init(ServiceContext* serviceCont
|
||||
// non-transaction, exclusive lock taking operation blocked
|
||||
// behind an active transaction's intent lock.
|
||||
opCtx->lockState()->setMaxLockTimeout(Milliseconds(0));
|
||||
|
||||
// This thread needs storage rollback to complete timely, so instruct the storage
|
||||
// engine to not do any extra eviction for this thread, if supported.
|
||||
opCtx->recoveryUnit()->setNoEvictionAfterRollback();
|
||||
|
||||
try {
|
||||
killAllExpiredTransactions(opCtx.get());
|
||||
} catch (ExceptionForCat<ErrorCategory::CancelationError>& ex) {
|
||||
|
@ -633,6 +633,14 @@ public:
|
||||
_mustBeTimestamped = true;
|
||||
}
|
||||
|
||||
void setNoEvictionAfterRollback() {
|
||||
_noEvictionAfterRollback = true;
|
||||
}
|
||||
|
||||
bool getNoEvictionAfterRollback() const {
|
||||
return _noEvictionAfterRollback;
|
||||
}
|
||||
|
||||
protected:
|
||||
RecoveryUnit();
|
||||
|
||||
@ -673,6 +681,8 @@ protected:
|
||||
|
||||
bool _mustBeTimestamped = false;
|
||||
|
||||
bool _noEvictionAfterRollback = false;
|
||||
|
||||
private:
|
||||
// Sets the snapshot associated with this RecoveryUnit to a new globally unique id number.
|
||||
void assignNextSnapshotId();
|
||||
|
@ -374,17 +374,22 @@ void WiredTigerRecoveryUnit::_txnClose(bool commit) {
|
||||
}
|
||||
|
||||
wtRet = s->commit_transaction(s, conf.str().c_str());
|
||||
LOGV2_DEBUG(22412,
|
||||
3,
|
||||
"WT commit_transaction for snapshot id {snapshotId}",
|
||||
"snapshotId"_attr = getSnapshotId().toNumber());
|
||||
|
||||
LOGV2_DEBUG(
|
||||
22412, 3, "WT commit_transaction", "snapshotId"_attr = getSnapshotId().toNumber());
|
||||
} else {
|
||||
wtRet = s->rollback_transaction(s, nullptr);
|
||||
invariant(!wtRet);
|
||||
LOGV2_DEBUG(22413,
|
||||
3,
|
||||
"WT rollback_transaction for snapshot id {snapshotId}",
|
||||
"snapshotId"_attr = getSnapshotId().toNumber());
|
||||
StringBuilder config;
|
||||
if (_noEvictionAfterRollback) {
|
||||
// The only point at which rollback_transaction() can time out is in the bonus-eviction
|
||||
// phase. If the timeout expires here, the function will stop the eviction and return
|
||||
// success. It cannot return an error due to timeout.
|
||||
config << "operation_timeout_ms=1,";
|
||||
}
|
||||
|
||||
wtRet = s->rollback_transaction(s, config.str().c_str());
|
||||
|
||||
LOGV2_DEBUG(
|
||||
22413, 3, "WT rollback_transaction", "snapshotId"_attr = getSnapshotId().toNumber());
|
||||
}
|
||||
|
||||
if (_isTimestamped) {
|
||||
|
@ -830,6 +830,10 @@ void TransactionParticipant::TxnResources::release(OperationContext* opCtx) {
|
||||
readConcernArgs = _readConcernArgs;
|
||||
}
|
||||
|
||||
void TransactionParticipant::TxnResources::setNoEvictionAfterRollback() {
|
||||
_recoveryUnit->setNoEvictionAfterRollback();
|
||||
}
|
||||
|
||||
TransactionParticipant::SideTransactionBlock::SideTransactionBlock(OperationContext* opCtx)
|
||||
: _opCtx(opCtx) {
|
||||
// Do nothing if we are already in a SideTransactionBlock. We can tell we are already in a
|
||||
@ -1662,6 +1666,9 @@ void TransactionParticipant::Participant::_abortTransactionOnSession(OperationCo
|
||||
: TransactionState::kAbortedWithoutPrepare;
|
||||
|
||||
stdx::lock_guard<Client> lk(*opCtx->getClient());
|
||||
if (o().txnResourceStash && opCtx->recoveryUnit()->getNoEvictionAfterRollback()) {
|
||||
o(lk).txnResourceStash->setNoEvictionAfterRollback();
|
||||
}
|
||||
_resetTransactionState(lk, nextState);
|
||||
}
|
||||
|
||||
|
@ -221,6 +221,8 @@ public:
|
||||
return _readConcernArgs;
|
||||
}
|
||||
|
||||
void setNoEvictionAfterRollback();
|
||||
|
||||
private:
|
||||
bool _released = false;
|
||||
std::unique_ptr<Locker> _locker;
|
||||
|
Loading…
Reference in New Issue
Block a user