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

Order writes to replication oplog under document-level locking

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.8.0-rc0
    • None
    • Replication, Storage
    • None

    Description

      With the current state of replication, writes to the oplog need to be ordered. This was guaranteed through the database lock in 2.6, but now with document-level locking this is no longer true, so we need to have something, which serializes writers, but doesn't block readers.

      One option is to add a 'REPL' lock resource. Might be able to do this with a simple boost mutex as well if we can prove that there cannot be deadlocks. Here is the sequence of an updater to a given database A:

      Lock (A, IX)
      Lock (A.Collection, IX)
      ... Do write using document-level locking, under the storage engine's transaction. Locks will be held till the end of the operation.
       
      Lock (REPL, X)
       
      Lock (LocalDB, IX)
      Lock (LocalDB.Collection, IX)
      ... Do write under the same storage engine transaction
       
      Unlock (REPL)       // This is a performance optimisation to release the lock early
       
      Unlock All other locks

      The oplog reader will look like this (it will skip locking the REPL resource):

      Lock (LocalDB, IS)
      Lock (LocalDB.Collection, IS)
      ... Locate the last unreplicated location
      Unlock All

      Attachments

        Activity

          People

            eliot Eliot Horowitz (Inactive)
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: