diff options
author | Matthew Russotto <matthew.russotto@mongodb.com> | 2022-04-29 14:47:45 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-16 16:35:44 +0000 |
commit | fa5d029fd8a6f06e42be69a1ba7842ca35e39333 (patch) | |
tree | 9e4a3c38c44e3e8a7936a9b79e5182bd6df5022e /src/mongo/db | |
parent | 6501f4a1e5cfd08bd2a51c1700e125f5e4933b90 (diff) | |
download | mongo-fa5d029fd8a6f06e42be69a1ba7842ca35e39333.tar.gz |
SERVER-66089 Initial sync should do transaction table read with a later afterClusterTime.
(cherry picked from commit 878b6bb32413dc105133ffac31e9a0cf21e930f4)
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/repl/initial_syncer.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index d1b9b699ada..02fb4af0be5 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -898,6 +898,10 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForDefaultBeginFetchingOpTime( std::string logMsg = str::stream() << "Initial Syncer got the defaultBeginFetchingTimestamp: " << defaultBeginFetchingOpTime.toString(); pauseAtInitialSyncFuzzerSyncronizationPoints(logMsg); + LOGV2_DEBUG(6608900, + 1, + "Initial Syncer got the defaultBeginFetchingOpTime", + "defaultBeginFetchingOpTime"_attr = defaultBeginFetchingOpTime); status = _scheduleGetBeginFetchingOpTime_inlock(onCompletionGuard, defaultBeginFetchingOpTime); if (!status.isOK()) { @@ -913,10 +917,10 @@ Status InitialSyncer::_scheduleGetBeginFetchingOpTime_inlock( const auto preparedState = DurableTxnState_serializer(DurableTxnStateEnum::kPrepared); const auto inProgressState = DurableTxnState_serializer(DurableTxnStateEnum::kInProgress); - // Obtain the oldest active transaction timestamp from the remote by querying their - // transactions table. To prevent oplog holes from causing this query to return an inaccurate - // timestamp, we specify an afterClusterTime of Timestamp(0, 1) so that we wait for all previous - // writes to be visible. + // Obtain the oldest active transaction timestamp from the remote by querying their transactions + // table. To prevent oplog holes (primary) or a stale lastAppliedSnapshot (secondary) from + // causing this query to return an inaccurate timestamp, we specify an afterClusterTime of the + // defaultBeginFetchingOpTime so that we wait for all previous writes to be visible. BSONObjBuilder cmd; cmd.append("find", NamespaceString::kSessionTransactionsTableNamespace.coll().toString()); cmd.append("filter", @@ -925,7 +929,7 @@ Status InitialSyncer::_scheduleGetBeginFetchingOpTime_inlock( cmd.append("readConcern", BSON("level" << "local" - << "afterClusterTime" << Timestamp(0, 1))); + << "afterClusterTime" << defaultBeginFetchingOpTime.getTimestamp())); cmd.append("limit", 1); _beginFetchingOpTimeFetcher = std::make_unique<Fetcher>( |