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

Deadlock involving repl snapshot thread

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.1.8
    • 3.1.6
    • Concurrency, Storage
    • None
    • Fully Compatible

    Description

      Found by the hang analyzer in a patch build running noPassthrough/backup_restore.js.

      The deadlock involves the "capped in flight" lock and the "local" database lock, and requires the participation of 4 threads.

      The first thread is inserting into a replicated capped collection. The second thread is inserting into a replicated plain collection. The third thread is the replication snapshot thread, and the fourth is any thread doing an operation that takes the local database lock in MODE_X, such as createIndexes or replSetReconfig.

      The capped insert thread locks its database and collection in MODE_IX, then the "capped in flight" lock in MODE_IX.

      The plain insert thread then locks its database and collection in MODE_IX and the local database lock in MODE_IX.

      The repl snapshot thread then attempts to get the "capped in flight" lock in MODE_X, and blocks.

      The 4th thread then attempts to get the "local" database lock in MODE_X, and blocks behind the plain insert thread.

      The capped insert thread then attempts to lock the "local" database in MODE_IX, and blocks behind thread 4.

      The plain insert thread then attempts to lock the "capped in flight" lock in MODE_IX and blocks behind the repl snapshot thread.

      Now, the capped insert thread is blocked on the fourth thread, which is blocked on the plain insert thread, which is blocked on the snapshot thread, which is blocked on the capped insert thread. Deadlock.

      Attachments

        Activity

          People

            mathias@mongodb.com Mathias Stearn
            schwerin@mongodb.com Andy Schwerin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: