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

Serialize concurrent accesses to `OperationContext::_comment`

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • Query Execution 2021-07-26, QE 2021-08-09
    • 138

      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).

            Assignee:
            jennifer.peshansky@mongodb.com Jennifer Peshansky (Inactive)
            Reporter:
            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: