-
Type:
Improvement
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Replication
-
Repl 2025-05-12
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
0
We added logging in SERVER-104743, but it only fires if both `_ti->isTransactionInProgress(_opCtx)` and `!_ti->isTransactionInProgress(_opCtx)`, which can never be true.
If we rewrite the code as follow, then it's more obvious that it's correct:
auto inProgress = _ti->isTransactionInProgress(_opCtx);
if (inProgress) {
auto state = _ti->transactionStateDescriptor(_opCtx);
auto txnNum = _opCtx->getTxnNumber().get_value_or(TxnNumber(-1));
auto txnRetries = _opCtx->getTxnRetryCounter().get_value_or(-1);
auto opId = _opCtx->getOpID();
auto sessionId = _opCtx->getClient()->session()->id();
auto lsid = _opCtx->getLogicalSessionId();
auto clientAddress = _opCtx->getClient()->clientAddress(true);
invariant(!inProgress,
str::stream() << "state: " << state << " txnNum: " << txnNum
<< " txnRetries: " << txnRetries << " opId: " << opId
<< " lsid: " << lsid << " sessionId: " << sessionId
<< " clientAddress: " << clientAddress);
}
- is related to
-
SERVER-104743 Add logging for transaction failure
-
- Closed
-