summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@mongodb.com>2021-02-05 11:31:12 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-08 16:06:31 +0000
commit7d63d668f001f63672905e8d5f63275c09ba84cd (patch)
tree0f8f7c5aaf96b1db371fd6c45fcfcaa0a2ad3733
parent3fb8a941f4624291e3091a1ff96dde4f62b772cd (diff)
downloadmongo-7d63d668f001f63672905e8d5f63275c09ba84cd.tar.gz
SERVER-54341 Must not capture locals by reference in asynchronous lambda (exhaust_cursor_currentop_integration_test.cpp)
-rw-r--r--src/mongo/db/exhaust_cursor_currentop_integration_test.cpp53
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();