summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2019-07-29 16:52:52 -0400
committerBlake Oler <blake.oler@mongodb.com>2019-07-31 10:54:11 -0400
commit381bb2c51c74b82f01b269b0f187d75b9b5c8adc (patch)
tree7924b8a9bfe4ea5908444c11e6394aac7a15d6b9 /src/mongo/s
parentc6ec415752c8398f588491d8af1c54ee4e7fcbb4 (diff)
downloadmongo-381bb2c51c74b82f01b269b0f187d75b9b5c8adc.tar.gz
SERVER-42457 Check if atClusterTime has been set on TransactionRouter before observing from an external thread
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/transaction_router.cpp10
-rw-r--r--src/mongo/s/transaction_router.h10
2 files changed, 19 insertions, 1 deletions
diff --git a/src/mongo/s/transaction_router.cpp b/src/mongo/s/transaction_router.cpp
index 8bfb6cbbb39..5d7d08fbafb 100644
--- a/src/mongo/s/transaction_router.cpp
+++ b/src/mongo/s/transaction_router.cpp
@@ -402,6 +402,10 @@ LogicalTime TransactionRouter::AtClusterTime::getTime() const {
return _atClusterTime;
}
+bool TransactionRouter::AtClusterTime::timeHasBeenSet() const {
+ return _atClusterTime != LogicalTime::kUninitialized;
+}
+
void TransactionRouter::AtClusterTime::setTime(LogicalTime atClusterTime, StmtId currentStmtId) {
invariant(atClusterTime != LogicalTime::kUninitialized);
_atClusterTime = atClusterTime;
@@ -682,6 +686,10 @@ void TransactionRouter::Router::setDefaultAtClusterTime(OperationContext* opCtx)
opCtx, repl::ReadConcernArgs::get(opCtx).getArgsAfterClusterTime(), defaultTime);
}
+bool TransactionRouter::Router::_atClusterTimeHasBeenSet() const {
+ return o().atClusterTime.is_initialized() && o().atClusterTime->timeHasBeenSet();
+}
+
void TransactionRouter::Router::_setAtClusterTime(
OperationContext* opCtx,
const boost::optional<LogicalTime>& afterClusterTime,
@@ -1140,7 +1148,7 @@ std::string TransactionRouter::Router::_transactionInfoForLog(
sb << "parameters:" << parametersBuilder.obj().toString() << ",";
- if (o().atClusterTime) {
+ if (_atClusterTimeHasBeenSet()) {
sb << " globalReadTimestamp:" << o().atClusterTime->getTime().toString() << ",";
}
diff --git a/src/mongo/s/transaction_router.h b/src/mongo/s/transaction_router.h
index 82e7498523a..cf225ef0f9c 100644
--- a/src/mongo/s/transaction_router.h
+++ b/src/mongo/s/transaction_router.h
@@ -171,6 +171,11 @@ public:
LogicalTime getTime() const;
/**
+ * Returns true if the _atClusterTime has been changed from the default uninitialized value.
+ */
+ bool timeHasBeenSet() const;
+
+ /**
* Sets the timestamp and remembers the statement id of the command that set it.
*/
void setTime(LogicalTime atClusterTime, StmtId currentStmtId);
@@ -403,6 +408,11 @@ public:
BSONObj _handOffCommitToCoordinator(OperationContext* opCtx);
/**
+ * Returns true if the atClusterTime has been changed from the default uninitialized value.
+ */
+ bool _atClusterTimeHasBeenSet() const;
+
+ /**
* Sets the given logical time as the atClusterTime for the transaction to be the greater of
* the given time and the user's afterClusterTime, if one was provided.
*/