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>2017-12-18 11:19:05 -0500
commit962c5c61c93776aa4d1a8efb67a1a80cb3bb2ad0 (patch)
tree9ad8558783798d7c694ec82a4eca648e41b68ca9 /src/mongo/dbtests
parente972d40e588e9d1b920a75086f0b36c603fbdd3d (diff)
downloadmongo-962c5c61c93776aa4d1a8efb67a1a80cb3bb2ad0.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/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) {