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

Better APIs for locking mode within/outside transactions

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Catalog and Routing
    • 1

    Description

      There is a recurring pattern across the codebase when having to choose the lock mode for acquisitions happening outside/within a transaction: we often manually check if the operation context is flagged as inMultiDocumentTransaction in order to use either intent shared mode or exclusive.

      Purpose of this ticket is to investigate whether there is a better way to do so without having to continuously manually check, for example automatically "promote" intent shared mode to exclusive based on the operation context flags.

      Some examples of manual checks spottable through a simple grep:

      $ git grep '? MODE_IX : MODE_IS' src/
      src/mongo/db/s/ddl_lock_manager.cpp:    const auto lockMode = opCtx->inMultiDocumentTransaction() ? MODE_IX : MODE_IS;
      src/mongo/db/s/ddl_lock_manager.cpp:        const auto lockMode = opCtx->inMultiDocumentTransaction() ? MODE_IX : MODE_IS;
      src/mongo/db/shard_role.cpp:        const auto lockMode = opCtx->inMultiDocumentTransaction() ? MODE_IX : MODE_IS;
      src/mongo/db/transaction/transaction_participant.cpp:    Lock::GlobalLock lk(opCtx, opCtx->inMultiDocumentTransaction() ? MODE_IX : MODE_IS);
      

      Attachments

        Activity

          People

            backlog-server-catalog-and-routing Backlog - Catalog and Routing
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: