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

Serialize concurrent accesses to `OperationContext::_comment`

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.1.0-rc0
    • Component/s: Internal Code
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Query Execution 2021-07-26, QE 2021-08-09
    • Linked BF Score:
      138

      Description

      SERVER-29794 added _comment as a new member of OperationContext, and exposed setComment()/getComment() to set/get the value of the new field.

      Accessing _comment, however, is not thread-safe, and to ensure thread-safety:

      • The client lock must be acquired before calling into setComment().
      • The client lock must be acquired to getComment() from any thread that does not own the client associated with the operation (i.e., Client::getCurrent() != opCtx->getClient()).

      The common practice is to use the client lock to serialize concurrent accesses to OperationContext fields that are not thread-safe. We currently do so to access _comment when preparing the currentOp output (see here).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jennifer.peshansky Jennifer Peshansky
              Reporter:
              amirsaman.memaripour Amirsaman Memaripour
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: