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

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

    • Fully Compatible
    • Storage 2017-11-13

      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@mongodb.com Xiangyu Yao (Inactive)
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: