summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorMartin Neupauer <martin.neupauer@mongodb.com>2017-12-14 14:25:52 -0500
committerMartin Neupauer <martin.neupauer@mongodb.com>2018-01-03 11:23:31 -0500
commit8d2276dfa94673f0ca1480fc87977a6f36c2816a (patch)
tree5128dc4b44a8fc060516c1f8745d82cdf099fb00 /src/mongo/dbtests
parent879db6231681408b5ca4bba8c49d2d5970986669 (diff)
downloadmongo-8d2276dfa94673f0ca1480fc87977a6f36c2816a.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. (cherry picked from commit 962c5c61c93776aa4d1a8efb67a1a80cb3bb2ad0)
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/documentsourcetests.cpp6
-rw-r--r--src/mongo/dbtests/query_plan_executor.cpp5
2 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp
index 97ddc5057df..db9ac3f47a6 100644
--- a/src/mongo/dbtests/documentsourcetests.cpp
+++ b/src/mongo/dbtests/documentsourcetests.cpp
@@ -311,7 +311,7 @@ TEST_F(DocumentSourceCursorTest, SerializationRespectsExplainModes) {
source()->dispose();
}
-TEST_F(DocumentSourceCursorTest, TailableAwaitDataCursorStillUsableAfterTimeout) {
+TEST_F(DocumentSourceCursorTest, TailableAwaitDataCursorShouldErrorAfterTimeout) {
// Make sure the collection exists, otherwise we'll default to a NO_YIELD yield policy.
const bool capped = true;
const long long cappedSize = 1024;
@@ -348,8 +348,8 @@ TEST_F(DocumentSourceCursorTest, TailableAwaitDataCursorStillUsableAfterTimeout)
auto cursor =
DocumentSourceCursor::create(readLock.getCollection(), std::move(planExecutor), ctx());
- ASSERT(cursor->getNext().isEOF());
- cursor->dispose();
+ ON_BLOCK_EXIT([cursor]() { cursor->dispose(); });
+ ASSERT_THROWS_CODE(cursor->getNext().isEOF(), AssertionException, ErrorCodes::QueryPlanKilled);
}
TEST_F(DocumentSourceCursorTest, NonAwaitDataCursorShouldErrorAfterTimeout) {
diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp
index 99a45b8a402..8f8025e4b9d 100644
--- a/src/mongo/dbtests/query_plan_executor.cpp
+++ b/src/mongo/dbtests/query_plan_executor.cpp
@@ -296,7 +296,7 @@ TEST_F(PlanExecutorTest, ShouldReportErrorIfExceedsTimeLimitDuringYield) {
ASSERT_EQ(ErrorCodes::ExceededTimeLimit, WorkingSetCommon::getMemberObjectStatus(resultObj));
}
-TEST_F(PlanExecutorTest, ShouldReportEOFIfExceedsTimeLimitDuringYieldButIsTailableAndAwaitData) {
+TEST_F(PlanExecutorTest, ShouldReportErrorIfKilledDuringYieldButIsTailableAndAwaitData) {
OldClientWriteContext ctx(&_opCtx, nss.ns());
insert(BSON("_id" << 1));
insert(BSON("_id" << 2));
@@ -310,7 +310,8 @@ TEST_F(PlanExecutorTest, ShouldReportEOFIfExceedsTimeLimitDuringYieldButIsTailab
TailableMode::kTailableAndAwaitData);
BSONObj resultObj;
- ASSERT_EQ(PlanExecutor::IS_EOF, exec->getNext(&resultObj, nullptr));
+ ASSERT_EQ(PlanExecutor::DEAD, exec->getNext(&resultObj, nullptr));
+ ASSERT_EQ(ErrorCodes::ExceededTimeLimit, WorkingSetCommon::getMemberObjectStatus(resultObj));
}
TEST_F(PlanExecutorTest, ShouldNotSwallowExceedsTimeLimitDuringYieldButIsTailableButNotAwaitData) {