summaryrefslogtreecommitdiff
path: root/src/mongo/s/query/async_results_merger.cpp
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@gmail.com>2017-11-06 03:49:57 +0000
committerBernard Gorman <bernard.gorman@gmail.com>2017-11-18 03:49:57 +0000
commited83e82fcd2731543724523e7fd2c8563ab717c9 (patch)
treec10337e8089f949eaed21a66bc662445fb14b675 /src/mongo/s/query/async_results_merger.cpp
parentc85b31b5d392b71cabf87bac1ac229a5a9ad62b4 (diff)
downloadmongo-ed83e82fcd2731543724523e7fd2c8563ab717c9.tar.gz
SERVER-31836 Always dispatch sorted tailable awaitdata getMores to the shards with timeouts of at most 1 second
Diffstat (limited to 'src/mongo/s/query/async_results_merger.cpp')
-rw-r--r--src/mongo/s/query/async_results_merger.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp
index 8bdc8e69353..241f09f209b 100644
--- a/src/mongo/s/query/async_results_merger.cpp
+++ b/src/mongo/s/query/async_results_merger.cpp
@@ -129,7 +129,15 @@ Status AsyncResultsMerger::setAwaitDataTimeout(Milliseconds awaitDataTimeout) {
"maxTimeMS can only be used with getMore for tailable, awaitData cursors");
}
- _awaitDataTimeout = awaitDataTimeout;
+ // For sorted tailable awaitData cursors on multiple shards, cap the getMore timeout at 1000ms.
+ // This is to ensure that we get a continuous stream of updates from each shard with their most
+ // recent optimes, which allows us to return sorted $changeStream results even if some shards
+ // are yet to provide a batch of data. If the timeout specified by the client is greater than
+ // 1000ms, then it will be enforced elsewhere.
+ _awaitDataTimeout = (!_params->sort.isEmpty() && _remotes.size() > 1u
+ ? std::min(awaitDataTimeout, Milliseconds{1000})
+ : awaitDataTimeout);
+
return Status::OK();
}