summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/collection.cpp
diff options
context:
space:
mode:
authorMartin Neupauer <martin.neupauer@mongodb.com>2017-11-15 15:38:14 -0500
committerMartin Neupauer <martin.neupauer@mongodb.com>2017-12-12 15:49:15 -0500
commitb79e5f04ffc79b5892f89c22b9e5f26a297b1185 (patch)
treeba924a0eb8e03751f3dd95a4461e53f877ceba19 /src/mongo/db/catalog/collection.cpp
parent847104b8775af27762b35ff99da0d78511c01376 (diff)
downloadmongo-b79e5f04ffc79b5892f89c22b9e5f26a297b1185.tar.gz
SERVER-31684 Fix unexpected "operation exceeded time limit" errors
The changestream queries used an operation context deadline to track a wait time before returning EOF. This occasionaly interfered with normal operation deadlines leading to unexpected errors.
Diffstat (limited to 'src/mongo/db/catalog/collection.cpp')
-rw-r--r--src/mongo/db/catalog/collection.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index 5d8e64a9bdd..6493d147605 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -152,33 +152,15 @@ void CappedInsertNotifier::notifyAll() {
_notifier.notify_all();
}
-void CappedInsertNotifier::_wait(stdx::unique_lock<stdx::mutex>& lk,
- uint64_t prevVersion,
- Microseconds timeout) const {
+void CappedInsertNotifier::waitUntil(uint64_t prevVersion, Date_t deadline) const {
+ stdx::unique_lock<stdx::mutex> lk(_mutex);
while (!_dead && prevVersion == _version) {
- if (timeout == Microseconds::max()) {
- _notifier.wait(lk);
- } else if (stdx::cv_status::timeout == _notifier.wait_for(lk, timeout.toSystemDuration())) {
+ if (stdx::cv_status::timeout == _notifier.wait_until(lk, deadline.toSystemTimePoint())) {
return;
}
}
}
-void CappedInsertNotifier::wait(uint64_t prevVersion, Microseconds timeout) const {
- stdx::unique_lock<stdx::mutex> lk(_mutex);
- _wait(lk, prevVersion, timeout);
-}
-
-void CappedInsertNotifier::wait(Microseconds timeout) const {
- stdx::unique_lock<stdx::mutex> lk(_mutex);
- _wait(lk, _version, timeout);
-}
-
-void CappedInsertNotifier::wait() const {
- stdx::unique_lock<stdx::mutex> lk(_mutex);
- _wait(lk, _version, Microseconds::max());
-}
-
void CappedInsertNotifier::kill() {
stdx::lock_guard<stdx::mutex> lk(_mutex);
_dead = true;