summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/find_cmd.cpp
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2020-09-29 21:30:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-13 21:38:46 +0000
commit9b519f5f01cfa98636b061785acdaf58a3dfcf77 (patch)
treec55eda44e8422f64e1be4b90a1feebd37fb4fdfa /src/mongo/db/commands/find_cmd.cpp
parent6831f81b2b84325a2ef4f8c74c71d478eeadb34a (diff)
downloadmongo-9b519f5f01cfa98636b061785acdaf58a3dfcf77.tar.gz
SERVER-51227 Make find/getMore cmd with $_requestResumeToken on oplog report latest oplog entry ts seen while generating the response batch
Diffstat (limited to 'src/mongo/db/commands/find_cmd.cpp')
-rw-r--r--src/mongo/db/commands/find_cmd.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 96d612b60e5..9e1c0f711fc 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -455,6 +455,7 @@ public:
BSONObj obj;
PlanExecutor::ExecState state = PlanExecutor::ADVANCED;
std::uint64_t numResults = 0;
+ bool stashedResult = false;
try {
while (!FindCommon::enoughForFirstBatch(originalQR, numResults) &&
@@ -463,6 +464,7 @@ public:
// later.
if (!FindCommon::haveSpaceForNext(obj, numResults, firstBatch.bytesUsed())) {
exec->enqueue(obj);
+ stashedResult = true;
break;
}
@@ -490,6 +492,13 @@ public:
throw;
}
+ // For empty batches, or in the case where the final result was added to the batch
+ // rather than being stashed, we update the PBRT to ensure that it is the most recent
+ // available.
+ if (!stashedResult) {
+ firstBatch.setPostBatchResumeToken(exec->getPostBatchResumeToken());
+ }
+
// Set up the cursor for getMore.
CursorId cursorId = 0;
if (shouldSaveCursor(opCtx, collection, state, exec.get())) {