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

Serialize concurrent accesses to `OperationContext::_comment`

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 5.1.0-rc0
    • Internal Code
    • None
    • Fully Compatible
    • ALL
    • Query Execution 2021-07-26, QE 2021-08-09
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: