diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2021-06-15 00:22:10 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-15 00:49:21 +0000 |
commit | e2fba06768ba16225951ec0735ec1665e4a549c9 (patch) | |
tree | 572ef5c2b6aee1654565f477d4cf66f3dfd15f14 | |
parent | 609b2e9fc8466e154e550b1b566460492ca7755d (diff) | |
download | mongo-e2fba06768ba16225951ec0735ec1665e4a549c9.tar.gz |
SERVER-57653 Dispose Pipeline in ReshardingDonorOplogIterator on error.
(cherry picked from commit f82785b6cb6075d3087e8af2545689764064d4a9)
-rw-r--r-- | src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp b/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp index d3d0839b68b..c8a89ab8466 100644 --- a/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp +++ b/src/mongo/db/s/resharding/resharding_donor_oplog_iterator.cpp @@ -205,6 +205,8 @@ ExecutorFuture<std::vector<repl::OplogEntry>> ReshardingDonorOplogIterator::getN auto batch = [&] { auto opCtx = factory.makeOperationContext(&cc()); + auto guard = makeGuard([&] { dispose(opCtx.get()); }); + if (_pipeline) { _pipeline->reattachToOperationContext(opCtx.get()); } else { @@ -214,17 +216,10 @@ ExecutorFuture<std::vector<repl::OplogEntry>> ReshardingDonorOplogIterator::getN pipeline.release()); _pipeline.get_deleter().dismissDisposal(); } - ON_BLOCK_EXIT([this] { - if (_pipeline) { - _pipeline->detachFromOperationContext(); - } - }); auto batch = _fillBatch(*_pipeline); - if (batch.empty()) { - dispose(opCtx.get()); - } else { + if (!batch.empty()) { const auto& lastEntryInBatch = batch.back(); _resumeToken = getId(lastEntryInBatch); @@ -232,7 +227,9 @@ ExecutorFuture<std::vector<repl::OplogEntry>> ReshardingDonorOplogIterator::getN _hasSeenFinalOplogEntry = true; // Skip returning the final oplog entry because it is known to be a no-op. batch.pop_back(); - dispose(opCtx.get()); + } else { + _pipeline->detachFromOperationContext(); + guard.dismiss(); } } |