Calls to take resource lock unnecessarily check for null Locker on OperationContext

XMLWordPrintableJSON

    • Fully Compatible
    • Storage 2017-11-13
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      std::unique_ptr<Lock::ResourceLock> rLk;
      if (!_isRsThreadSafe && opCtx->lockState()) {
          rLk.reset(new Lock::ResourceLock(opCtx->lockState(), resourceIdCatalogMetadata, MODE_X));
      }
      

      Prior to https://github.com/mongodb/mongo/commit/12d82c741061da23a442086465322352f157d094#diff-a7d065bc58d47728c995d090e64d88ad, it was possible for an OperationContextNoop to return a nullptr when OperationContext::lockState() was called. This was done to allow use of the KVCatalog class in C++ unit tests against storage engines that don't support document-level concurrency. However, OperationContext::lockState() should never return nullptr after the introduction of the LockerNoop class, so the additional && opCtx->lockState() condition can be removed.

              Assignee:
              Xiangyu Yao (Inactive)
              Reporter:
              Max Hirschhorn
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: