summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@gmail.com>2019-07-15 11:15:19 +0100
committerBernard Gorman <bernard.gorman@gmail.com>2019-07-19 02:24:50 +0100
commit417d1a712e9f040d54beca8e4943edce218e9a8c (patch)
treefc98767f6cedbc0b600d9f075fcd1b6fd1761542 /src
parentc6b7ac3206ec53add5dc735e75adef22d931c699 (diff)
downloadmongo-r4.0.11.tar.gz
SERVER-42232 Adding a new shard renders all preceding resume tokens invalidr4.0.11-rc0r4.0.11
(cherry picked from commit ffdb59938db0dfc8ec48e8b74df7a54d07b3a128)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/document_source_check_resume_token.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/document_source_check_resume_token.cpp b/src/mongo/db/pipeline/document_source_check_resume_token.cpp
index fab7fcf2e5f..8f9928631a9 100644
--- a/src/mongo/db/pipeline/document_source_check_resume_token.cpp
+++ b/src/mongo/db/pipeline/document_source_check_resume_token.cpp
@@ -297,10 +297,17 @@ void DocumentSourceShardCheckResumability::_assertOplogHasEnoughHistory(
pExpCtx->mongoProcessInterface->makePipeline({matchSpec}, firstEntryExpCtx));
if (auto first = pipeline->getNext()) {
auto firstOplogEntry = Value(*first);
+ // If the first entry in the oplog is the replset initialization, then it doesn't matter
+ // if its timestamp is later than the resume token. No events earlier than the token can
+ // have fallen off this oplog, and it is therefore safe to resume. Otherwise, verify that
+ // the timestamp of the first oplog entry is earlier than that of the resume token.
+ const bool isNewRS =
+ Value::compare(firstOplogEntry["o"]["msg"], Value("initiating set"_sd), nullptr) == 0 &&
+ Value::compare(firstOplogEntry["op"], Value("n"_sd), nullptr) == 0;
uassert(40576,
- "Resume of change stream was not possible, as the resume point may no longer "
- "be in the oplog. ",
- firstOplogEntry["ts"].getTimestamp() < _tokenFromClient.clusterTime);
+ "Resume of change stream was not possible, as the resume point may no longer be in "
+ "the oplog. ",
+ isNewRS || firstOplogEntry["ts"].getTimestamp() < _tokenFromClient.clusterTime);
} else {
// Very unusual case: the oplog is empty. We can always resume. However, it should never be
// possible to have obtained a document that matched the filter if the oplog is empty.