summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/s/query/cluster_cursor_cleanup_job.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/s/query/cluster_cursor_cleanup_job.cpp b/src/mongo/s/query/cluster_cursor_cleanup_job.cpp
index c222abf921f..a8892131cd0 100644
--- a/src/mongo/s/query/cluster_cursor_cleanup_job.cpp
+++ b/src/mongo/s/query/cluster_cursor_cleanup_job.cpp
@@ -68,8 +68,13 @@ void ClusterCursorCleanupJob::run() {
invariant(manager);
while (!globalInShutdownDeprecated()) {
- manager->killMortalCursorsInactiveSince(Date_t::now() -
- Milliseconds(cursorTimeoutMillis.load()));
+ // Mirroring the behavior in CursorManager::timeoutCursors(), a negative value for
+ // cursorTimeoutMillis has the same effect as a 0 value: cursors are cleaned immediately.
+ auto cursorTimeoutValue = cursorTimeoutMillis.load();
+ Date_t cutoff = (cursorTimeoutValue > 0)
+ ? (Date_t::now() - Milliseconds(cursorTimeoutValue))
+ : Date_t::now();
+ manager->killMortalCursorsInactiveSince(cutoff);
manager->incrementCursorsTimedOut(manager->reapZombieCursors());
MONGO_IDLE_THREAD_BLOCK;