diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/commands/getmore_cmd.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/commands/getmore_cmd.cpp')
| -rw-r--r-- | src/mongo/db/commands/getmore_cmd.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 8d7510a7e2f..b3c00996ec6 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -431,6 +431,7 @@ 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), @@ -616,6 +617,7 @@ public: options.atClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime(); } CursorResponseBuilder nextBatch(reply, options); + BSONObj obj; std::uint64_t numResults = 0; ResourceConsumption::DocumentUnitCounter docUnitsReturned; @@ -632,7 +634,9 @@ public: // Use the commit point of the last batch for exhaust cursors. lastKnownCommittedOpTime = cursorPin->getLastKnownCommittedOpTime(); } - clientsLastKnownCommittedOpTime(opCtx) = lastKnownCommittedOpTime; + if (lastKnownCommittedOpTime) { + clientsLastKnownCommittedOpTime(opCtx) = lastKnownCommittedOpTime.get(); + } awaitDataState(opCtx).shouldWaitForInserts = true; } @@ -695,19 +699,10 @@ public: cursorPin->setLeftoverMaxTimeMicros(opCtx->getRemainingMaxTimeMicros()); - 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. + if (opCtx->isExhaust() && !clientsLastKnownCommittedOpTime(opCtx).isNull()) { + // Set the commit point of the latest batch. auto replCoord = repl::ReplicationCoordinator::get(opCtx); - auto myLastCommittedOpTime = replCoord->getLastCommittedOpTime(); - auto clientsLastKnownCommittedOpTime = cursorPin->getLastKnownCommittedOpTime(); - if (!clientsLastKnownCommittedOpTime.has_value() || - clientsLastKnownCommittedOpTime.value() < myLastCommittedOpTime) { - cursorPin->setLastKnownCommittedOpTime(myLastCommittedOpTime); - } + cursorPin->setLastKnownCommittedOpTime(replCoord->getLastCommittedOpTime()); } } else { curOp->debug().cursorExhausted = true; @@ -719,9 +714,12 @@ public: // documents. auto& metricsCollector = ResourceConsumption::MetricsCollector::get(opCtx); metricsCollector.incrementDocUnitsReturned(docUnitsReturned); - curOp->debug().additiveMetrics.nBatches = 1; - curOp->setEndOfOpMetrics(numResults); - collectQueryStatsMongod(opCtx, cursorPin); + cursorPin->incNReturnedSoFar(numResults); + cursorPin->incNBatches(); + + // Ensure log and profiler include the number of results returned in this getMore's + // response batch. + curOp->debug().nreturned = numResults; if (respondWithId) { cursorDeleter.dismiss(); |
