diff options
author | Matthew Russotto <matthew.russotto@10gen.com> | 2017-07-14 17:15:52 -0400 |
---|---|---|
committer | Matthew Russotto <matthew.russotto@10gen.com> | 2017-07-17 08:52:57 -0400 |
commit | 3d38a6ff86b47b71d735b77f39704adec3ef3da7 (patch) | |
tree | 8f318b2b52852a1511ed6da6ede9ac62cbe67d4d /src/mongo/db/query/plan_yield_policy.cpp | |
parent | a1c67941bf08c69cab04eba20bc9ce9a763e1c7f (diff) | |
download | mongo-3d38a6ff86b47b71d735b77f39704adec3ef3da7.tar.gz |
SERVER-29128 Fix performance regression on awaitData with lastKnownCommittedOpTime
Revert "Revert "SERVER-29128 Make $changeNotification stage return a tailable, awaitData cursor that continuously gives out oplog entries""
This reverts commit d29e92cffcb4db3cdd77b1e53d5d005db6cc309d.
Diffstat (limited to 'src/mongo/db/query/plan_yield_policy.cpp')
-rw-r--r-- | src/mongo/db/query/plan_yield_policy.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/db/query/plan_yield_policy.cpp b/src/mongo/db/query/plan_yield_policy.cpp index 52633ea0185..c5b54a90afb 100644 --- a/src/mongo/db/query/plan_yield_policy.cpp +++ b/src/mongo/db/query/plan_yield_policy.cpp @@ -71,7 +71,19 @@ void PlanYieldPolicy::resetTimer() { _elapsedTracker.resetLastTime(); } -bool PlanYieldPolicy::yield(RecordFetcher* fetcher) { +bool PlanYieldPolicy::yield(RecordFetcher* recordFetcher) { + invariant(_planYielding); + if (recordFetcher) { + OperationContext* opCtx = _planYielding->getOpCtx(); + return yield([recordFetcher, opCtx] { recordFetcher->setup(opCtx); }, + [recordFetcher] { recordFetcher->fetch(); }); + } else { + return yield(nullptr, nullptr); + } +} + +bool PlanYieldPolicy::yield(stdx::function<void()> beforeYieldingFn, + stdx::function<void()> whileYieldingFn) { invariant(_planYielding); invariant(canAutoYield()); @@ -107,7 +119,9 @@ bool PlanYieldPolicy::yield(RecordFetcher* fetcher) { opCtx->recoveryUnit()->abandonSnapshot(); } else { // Release and reacquire locks. - QueryYield::yieldAllLocks(opCtx, fetcher, _planYielding->nss()); + if (beforeYieldingFn) + beforeYieldingFn(); + QueryYield::yieldAllLocks(opCtx, whileYieldingFn, _planYielding->nss()); } return _planYielding->restoreStateWithoutRetrying(); |