Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-37689

Make recovery from query yield interruptible

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Internal Code, Querying
    • None

      PROBLEM
      The server query yielding mechanism uses the saveLockStateAndUnlock/restoreLockState combination of calls in order to get the lock state free all its acquired locks and then re-acquire them.

      The re-acquisition of the locks currently must run with UninterruptibleLockGuard because otherwise the interruption exception will unwind to the lock manager's RAII classes destructors and they will try to unlock an already unlocked resource id.

      Not being able to interrupt the restoreLockState call though is problematic because it can lead to deadlocks, which would otherwise get resolved automatically.

      PROPOSED SOLUTION
      I propose making restoreLockState interruptible by introducing an internal variable on the Locker, called boost::optional<LockSnapshot> _yieldedLocks and making saveLockStateAndUnlock place the locks it yielded inside this variable instead of returning them as an output parameter.

      restoreLockState will use the values in _yieldedLocks to reacquire the locks back and if it gets interrupted, the Locker::unlock calls can check if a lock was yielded inside the _yieldedLocks list.

            Assignee:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Reporter:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: