summaryrefslogtreecommitdiff
path: root/src/mongo/db/operation_context.h
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2018-07-20 09:05:04 -0400
committerJames Wahlin <james@mongodb.com>2018-07-24 13:09:41 -0400
commit35528523c00b72a210dc5b78a427d90ed1c14331 (patch)
treee666ffa680ffc39ca0bdbce323ac2fb116dedf6a /src/mongo/db/operation_context.h
parent9175c4deba82dc35606d14428d1bf0d8b43d7a6c (diff)
downloadmongo-35528523c00b72a210dc5b78a427d90ed1c14331.tar.gz
SERVER-35031 Return MaxTimeMSExpired for maxTimeMS timeout
Adds a new 'MaxTimeMSExpired' error code, returned when a timeout occurs due to exceeding of maxTimeMS. Timeouts unrelated to maxTimeMS will continue to return 'ExceededTimeLimit'.
Diffstat (limited to 'src/mongo/db/operation_context.h')
-rw-r--r--src/mongo/db/operation_context.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h
index c188f43c103..96c2fecc76e 100644
--- a/src/mongo/db/operation_context.h
+++ b/src/mongo/db/operation_context.h
@@ -377,22 +377,22 @@ public:
*
* To remove a deadline, pass in Date_t::max().
*/
- void setDeadlineByDate(Date_t when);
+ void setDeadlineByDate(Date_t when, ErrorCodes::Error timeoutError);
/**
* Sets the deadline for this operation to the maxTime plus the current time reported
* by the ServiceContext's fast clock source.
*/
- void setDeadlineAfterNowBy(Microseconds maxTime);
+ void setDeadlineAfterNowBy(Microseconds maxTime, ErrorCodes::Error timeoutError);
template <typename D>
- void setDeadlineAfterNowBy(D maxTime) {
+ void setDeadlineAfterNowBy(D maxTime, ErrorCodes::Error timeoutError) {
if (maxTime <= D::zero()) {
maxTime = D::zero();
}
if (maxTime <= Microseconds::max()) {
- setDeadlineAfterNowBy(duration_cast<Microseconds>(maxTime));
+ setDeadlineAfterNowBy(duration_cast<Microseconds>(maxTime), timeoutError);
} else {
- setDeadlineByDate(Date_t::max());
+ setDeadlineByDate(Date_t::max(), timeoutError);
}
}
@@ -436,7 +436,7 @@ private:
* Sets the deadline and maxTime as described. It is up to the caller to ensure that
* these correctly correspond.
*/
- void setDeadlineAndMaxTime(Date_t when, Microseconds maxTime);
+ void setDeadlineAndMaxTime(Date_t when, Microseconds maxTime, ErrorCodes::Error timeoutError);
/**
* Compute maxTime based on the given deadline.
@@ -501,6 +501,8 @@ private:
Date_t _deadline =
Date_t::max(); // The timepoint at which this operation exceeds its time limit.
+ ErrorCodes::Error _timeoutError = ErrorCodes::ExceededTimeLimit;
+
// Max operation time requested by the user or by the cursor in the case of a getMore with no
// user-specified maxTime. This is tracked with microsecond granularity for the purpose of
// assigning unused execution time back to a cursor at the end of an operation, only. The