diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-14 14:26:38 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-14 14:26:38 -0300 |
| commit | 294bc6ecabf14c09c9bc8644704921dcf97cb44e (patch) | |
| tree | 279b1e0bab53901a1647ac63c1c724f0f789a663 /src/mongo/db/commands/getmore_cmd.cpp | |
| parent | 70be7c27a251621187a1de533462ae2bb1e3bd39 (diff) | |
| parent | 1e917fd798aa25b7066d4b414b51184f13d5a092 (diff) | |
Update upstream source from tag 'upstream/6.0.10'debian/6.0.10-1
Update to upstream version '6.0.10'
with Debian dir 2d176fa254eee97b139f712fec5709641335a8c3
Diffstat (limited to 'src/mongo/db/commands/getmore_cmd.cpp')
| -rw-r--r-- | src/mongo/db/commands/getmore_cmd.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index b3c00996ec6..c699a3262e7 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -431,7 +431,6 @@ public: auto&& [stats, _] = explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats); LOGV2_WARNING(20478, - "getMore command executor error: {error}, stats: {stats}, cmd: {cmd}", "getMore command executor error", "error"_attr = exception.toStatus(), "stats"_attr = redact(stats), @@ -617,7 +616,6 @@ public: options.atClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime(); } CursorResponseBuilder nextBatch(reply, options); - BSONObj obj; std::uint64_t numResults = 0; ResourceConsumption::DocumentUnitCounter docUnitsReturned; @@ -634,9 +632,7 @@ public: // Use the commit point of the last batch for exhaust cursors. lastKnownCommittedOpTime = cursorPin->getLastKnownCommittedOpTime(); } - if (lastKnownCommittedOpTime) { - clientsLastKnownCommittedOpTime(opCtx) = lastKnownCommittedOpTime.get(); - } + clientsLastKnownCommittedOpTime(opCtx) = lastKnownCommittedOpTime; awaitDataState(opCtx).shouldWaitForInserts = true; } @@ -699,10 +695,19 @@ public: cursorPin->setLeftoverMaxTimeMicros(opCtx->getRemainingMaxTimeMicros()); - if (opCtx->isExhaust() && !clientsLastKnownCommittedOpTime(opCtx).isNull()) { - // Set the commit point of the latest batch. + if (opCtx->isExhaust() && clientsLastKnownCommittedOpTime(opCtx)) { + // Update the cursor's lastKnownCommittedOpTime to the current + // lastCommittedOpTime. The lastCommittedOpTime now may be staler than the + // actual lastCommittedOpTime returned in the metadata of this latest batch (see + // appendReplyMetadata). As a result, we may sometimes return more empty + // batches than we need to. But it is fine to be conservative in this. auto replCoord = repl::ReplicationCoordinator::get(opCtx); - cursorPin->setLastKnownCommittedOpTime(replCoord->getLastCommittedOpTime()); + auto myLastCommittedOpTime = replCoord->getLastCommittedOpTime(); + auto clientsLastKnownCommittedOpTime = cursorPin->getLastKnownCommittedOpTime(); + if (!clientsLastKnownCommittedOpTime.has_value() || + clientsLastKnownCommittedOpTime.value() < myLastCommittedOpTime) { + cursorPin->setLastKnownCommittedOpTime(myLastCommittedOpTime); + } } } else { curOp->debug().cursorExhausted = true; |
