Details
-
Improvement
-
Resolution: Incomplete
-
Major - P3
-
None
-
None
-
None
Description
PlanExecutor currently performs temprelease-style yielding through a PlanYieldPolicy while inside a call to PlanExecutor::getNext(). This causes yield lock release to happen in code where the acquiring lock is not in scope. PlanExecutors should not know about locks or yielding, and yielding should only happen with explicit manipulation of the lock objects. This way, a reader of a function that acquires a Lock::DBLock can easily reason about how long the lock is held (today, such a reader has to scour the function for hints that one of its subroutines might induce a yield as a hidden side effect).
PlanExecutor::getNext() should perform no yielding on its own, but instead should take a boolean functor as an additional optional argument that is evaluated on each work cycle. When the functor indicates that the time is right, the getNext() call should pass a NEED_YIELD return value to the caller instead of a document to be returned. The caller should then handle this yield request as it pleases.