diff options
Diffstat (limited to 'src/mongo/db/exhaust_cursor_currentop_integration_test.cpp')
-rw-r--r-- | src/mongo/db/exhaust_cursor_currentop_integration_test.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp b/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp index 7a8801538d0..e8a167ccdcc 100644 --- a/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp +++ b/src/mongo/db/exhaust_cursor_currentop_integration_test.cpp @@ -142,29 +142,38 @@ auto startExhaustQuery( Milliseconds awaitDataTimeoutMS = Milliseconds(5000), const boost::optional<repl::OpTime>& lastKnownCommittedOpTime = boost::none) { queryOptions = queryOptions | QueryOption_Exhaust; - auto queryThread = stdx::async(stdx::launch::async, [&] { - const auto projSpec = BSON("_id" << 0 << "a" << 1); - // Issue the initial 'find' with a batchSize of 2 and the exhaust flag set. We then iterate - // through the first batch and confirm that the results are as expected. - queryCursor = queryConnection->query(testNSS, {}, 0, 0, &projSpec, queryOptions, 2); - for (int i = 0; i < 2; ++i) { - ASSERT_BSONOBJ_EQ(queryCursor->nextSafe(), BSON("a" << i)); - } - // Having exhausted the two results returned by the initial find, we set the batchSize to 1 - // and issue a single getMore via DBClientCursor::more(). Because the 'exhaust' flag is set, - // the server will generate a series of internal getMores and stream them back to the client - // until the cursor is exhausted, without the client sending any further getMore requests. - // We expect this request to hang at the 'waitWithPinnedCursorDuringGetMoreBatch' failpoint. - queryCursor->setBatchSize(1); - if ((queryOptions & QueryOption_CursorTailable) && (queryOptions & QueryOption_AwaitData)) { - queryCursor->setAwaitDataTimeoutMS(awaitDataTimeoutMS); - if (lastKnownCommittedOpTime) { - auto term = lastKnownCommittedOpTime.get().getTerm(); - queryCursor->setCurrentTermAndLastCommittedOpTime(term, lastKnownCommittedOpTime); + auto queryThread = stdx::async( + stdx::launch::async, + [&queryCursor, + queryConnection, + queryOptions, + awaitDataTimeoutMS, + lastKnownCommittedOpTime] { + const auto projSpec = BSON("_id" << 0 << "a" << 1); + // Issue the initial 'find' with a batchSize of 2 and the exhaust flag set. We then + // iterate through the first batch and confirm that the results are as expected. + queryCursor = queryConnection->query(testNSS, {}, 0, 0, &projSpec, queryOptions, 2); + for (int i = 0; i < 2; ++i) { + ASSERT_BSONOBJ_EQ(queryCursor->nextSafe(), BSON("a" << i)); } - } - ASSERT(queryCursor->more()); - }); + // Having exhausted the two results returned by the initial find, we set the batchSize + // to 1 and issue a single getMore via DBClientCursor::more(). Because the 'exhaust' + // flag is set, the server will generate a series of internal getMores and stream them + // back to the client until the cursor is exhausted, without the client sending any + // further getMore requests. We expect this request to hang at the + // 'waitWithPinnedCursorDuringGetMoreBatch' failpoint. + queryCursor->setBatchSize(1); + if ((queryOptions & QueryOption_CursorTailable) && + (queryOptions & QueryOption_AwaitData)) { + queryCursor->setAwaitDataTimeoutMS(awaitDataTimeoutMS); + if (lastKnownCommittedOpTime) { + auto term = lastKnownCommittedOpTime.get().getTerm(); + queryCursor->setCurrentTermAndLastCommittedOpTime(term, + lastKnownCommittedOpTime); + } + } + ASSERT(queryCursor->more()); + }); // Wait until the parallel operation initializes its cursor. const auto startTime = clock->now(); |