diff options
author | Jason Rassi <rassi@10gen.com> | 2015-11-06 19:36:05 -0500 |
---|---|---|
committer | Jason Rassi <rassi@10gen.com> | 2015-11-06 19:43:13 -0500 |
commit | 11b757cc07e85f6a1b47ba1b2810f773003217be (patch) | |
tree | 62ef06c3af8917bdfca876936c02f468591bfafd /src | |
parent | 90bcb44cc6c284d810c2c5b80d56f947408e9e2d (diff) | |
download | mongo-11b757cc07e85f6a1b47ba1b2810f773003217be.tar.gz |
SERVER-21341 PlanYieldPolicy::resetTimer() call should be post-yield
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/query/plan_yield_policy.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/query/plan_yield_policy.cpp b/src/mongo/db/query/plan_yield_policy.cpp index 2a169a7920c..b03ec44920b 100644 --- a/src/mongo/db/query/plan_yield_policy.cpp +++ b/src/mongo/db/query/plan_yield_policy.cpp @@ -35,6 +35,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_yield.h" +#include "mongo/util/scopeguard.h" namespace mongo { @@ -61,8 +62,10 @@ bool PlanYieldPolicy::yield(RecordFetcher* fetcher) { invariant(_planYielding); invariant(allowedToYield()); - // Reset the yield timer in order to prevent from yielding again right away. - resetTimer(); + // After we finish yielding (or in any early return), call resetTimer() to prevent yielding + // again right away. We delay the resetTimer() call so that the clock doesn't start ticking + // until after we return from the yield. + ON_BLOCK_EXIT([this]() { resetTimer(); }); _forceYield = false; |