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

Do not hold replication mutex when calling getMinValid

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.7, 4.0.2, 4.1.2
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Fully Compatible
    • ALL
    • v4.0, v3.6
    • Repl 2018-08-13
    • 63

      It is not valid to read collections while holding the replication mutex. The reason is that reading a collection takes the global lock, which may be held by another thread, and that thread may be waiting on the replication mutex (e.g. by calling getMyLastAppliedOpTime).

      Thus, _replicationProcess->getConsistencyMarkers->getMinValid must not be called with the replication mutex held, as it is in _finishLoadLocalConfig.

      I believe we may simply release the repl mutex before checking !lastOpTime.isNull()

      https://github.com/mongodb/mongo/blob/960fca37a78040d75d87f8049ef4c4a6227506cc/src/mongo/db/repl/replication_coordinator_impl.cpp#L598

      Then re-acquire after calling getMinValid() (and remove the else clause).

            Assignee:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Reporter:
            matthew.russotto@mongodb.com Matthew Russotto
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: