summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/oplog_fetcher.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp4
2 files changed, 7 insertions, 3 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp
index 659b171ea12..0aa50c4be16 100644
--- a/src/mongo/db/repl/oplog_fetcher.cpp
+++ b/src/mongo/db/repl/oplog_fetcher.cpp
@@ -350,9 +350,9 @@ BSONObj OplogFetcher::_makeFindCommandObject(const NamespaceString& nss,
cmdBob.append("term", term);
}
- // This ensures that the sync source never returns an empty batch of documents for the first set
- // of results.
- cmdBob.append("readConcern", BSON("afterClusterTime" << lastOpTimeFetched.getTimestamp()));
+ // This ensures that the sync source waits for all earlier oplog writes to be visible.
+ // Since Timestamp(0, 0) isn't allowed, Timestamp(0, 1) is the minimal we can use.
+ cmdBob.append("readConcern", BSON("afterClusterTime" << Timestamp(0, 1)));
return cmdBob.obj();
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 305434968a2..9404577671d 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -1478,6 +1478,10 @@ Status ReplicationCoordinatorImpl::_waitUntilOpTime(OperationContext* opCtx,
// We wait only on primaries, because on secondaries, other mechanisms assure that the
// last applied optime is always hole-free, and waiting for all earlier writes to be visible
// can deadlock against secondary command application.
+ //
+ // Note that oplog queries by secondary nodes depend on this behavior to wait for
+ // all oplog holes to be filled in, despite providing an afterClusterTime field
+ // with Timestamp(0,1).
_storage->waitForAllEarlierOplogWritesToBeVisible(opCtx, /* primaryOnly =*/true);
}