summaryrefslogtreecommitdiff
path: root/src/mongo/db/transaction_participant.cpp
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2020-08-24 12:52:45 +0200
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-26 07:39:37 +0000
commit4dc5ad1c019849f2084bb9d30419d303679e6afe (patch)
treed6145dc37b9b112d34a32f2bedf9775bcaf40df3 /src/mongo/db/transaction_participant.cpp
parent9143e670375cbb8bf95e1018ea0afa4adf831607 (diff)
downloadmongo-4dc5ad1c019849f2084bb9d30419d303679e6afe.tar.gz
SERVER-50054 Advance logicalClock on transactionParticipant to commitTimestamp upon receiving commitTransaction
Diffstat (limited to 'src/mongo/db/transaction_participant.cpp')
-rw-r--r--src/mongo/db/transaction_participant.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp
index 5a63291993d..d90a57692eb 100644
--- a/src/mongo/db/transaction_participant.cpp
+++ b/src/mongo/db/transaction_participant.cpp
@@ -64,6 +64,7 @@
#include "mongo/db/storage/flow_control.h"
#include "mongo/db/transaction_history_iterator.h"
#include "mongo/db/transaction_participant_gen.h"
+#include "mongo/db/vector_clock_mutable.h"
#include "mongo/logv2/log.h"
#include "mongo/util/fail_point.h"
#include "mongo/util/log_with_sampling.h"
@@ -1392,11 +1393,16 @@ void TransactionParticipant::Participant::commitPreparedTransaction(
OplogSlot commitOplogSlot;
boost::optional<OplogSlotReserver> oplogSlotReserver;
- // On primary, we reserve an oplog slot before committing the transaction so that no
- // writes that are causally related to the transaction commit enter the oplog at a
- // timestamp earlier than the commit oplog entry.
if (opCtx->writesAreReplicated()) {
invariant(!commitOplogEntryOpTime);
+ // When this receiving node is not in a readable state, the cluster time gossiping
+ // protocol is not enabled, thus it is necessary to advance it explicitely,
+ // so that causal consistency is maintained in these situations.
+ VectorClockMutable::get(opCtx)->tickClusterTimeTo(LogicalTime(commitTimestamp));
+
+ // On primary, we reserve an oplog slot before committing the transaction so that no
+ // writes that are causally related to the transaction commit enter the oplog at a
+ // timestamp earlier than the commit oplog entry.
oplogSlotReserver.emplace(opCtx);
commitOplogSlot = oplogSlotReserver->getLastSlot();
invariant(commitOplogSlot.getTimestamp() >= commitTimestamp,