summaryrefslogtreecommitdiff
path: root/src/mongo/db/cursor_manager.cpp
diff options
context:
space:
mode:
authorRomans Kasperovics <romans.kasperovics@mongodb.com>2022-12-21 23:26:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-22 00:14:03 +0000
commitf293955ab3c651cf79217fcf3e9c5fbd4b2ce541 (patch)
tree13e7e8b0443473c766ccc84c1b842f5e914db2da /src/mongo/db/cursor_manager.cpp
parent322a935324c833adaa49593a116e943179305c90 (diff)
downloadmongo-f293955ab3c651cf79217fcf3e9c5fbd4b2ce541.tar.gz
SERVER-67722 Add special handling for MaxTimeMSExpired in shard cursor lifecycle
Diffstat (limited to 'src/mongo/db/cursor_manager.cpp')
-rw-r--r--src/mongo/db/cursor_manager.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mongo/db/cursor_manager.cpp b/src/mongo/db/cursor_manager.cpp
index 2ed5da7e80b..0c1fdecaa84 100644
--- a/src/mongo/db/cursor_manager.cpp
+++ b/src/mongo/db/cursor_manager.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/query/query_knobs_gen.h"
+#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/service_context.h"
#include "mongo/db/session/kill_sessions_common.h"
#include "mongo/db/session/logical_session_cache.h"
@@ -260,7 +261,8 @@ void CursorManager::unpin(OperationContext* opCtx,
// interesting in proactively cleaning up that cursor's resources. In these cases, we
// proactively delete the cursor. In other cases we preserve the error code so that the client
// will see the reason the cursor was killed when asking for the next batch.
- if (interruptStatus == ErrorCodes::Interrupted || interruptStatus == ErrorCodes::CursorKilled) {
+ if (interruptStatus == ErrorCodes::Interrupted || interruptStatus == ErrorCodes::CursorKilled ||
+ (cursor->cameFromRouter() && interruptStatus == ErrorCodes::MaxTimeMSExpired)) {
LOGV2(20530,
"removing cursor {cursor_cursorid} after completing batch: {error}",
"Removing cursor after completing batch",
@@ -371,6 +373,7 @@ ClientCursorPin CursorManager::registerCursor(OperationContext* opCtx,
std::unique_ptr<ClientCursor, ClientCursor::Deleter> clientCursor(
new ClientCursor(std::move(cursorParams), cursorId, opCtx, now));
+ clientCursor->setCameFromRouter(OperationShardingState::isComingFromRouter(opCtx));
// Register this cursor for lookup by transaction.
if (opCtx->getLogicalSessionId() && opCtx->getTxnNumber()) {