Locks for capped collection's metadata in CollectionImpl don't seem to do what they claim

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Community Answered
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      There are two identical pieces of code in CollectionImpl::_insertDocuments() and CollectionImpl::updateDocument() that grab metadata X-lock for capped collections:

       

      if (_shared->_needCappedLock) {
       // X-lock the metadata resource for this capped collection until the end of the WUOW. This
       // prevents the primary from executing with more concurrency than secondaries.
       // See SERVER-21646.
       Lock::ResourceLock heldUntilEndOfWUOW{
       opCtx->lockState(), ResourceId(RESOURCE_METADATA, _ns.ns()), MODE_X};
      }

      The lock won't be held until the end of WUOW as it will be released after leaving the scope.

      Is the comment wrong or is the code wrong?

            Assignee:
            Dmitry Agranat
            Reporter:
            Denis Protivensky
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: