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

ClientMetadata Parsing errors can leave ClientMetadataState decoration in invalid state

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v5.0, v4.4, v4.2
    • Sprint:
      Service Arch 2021-06-28
    • Linked BF Score:
      133

      Description

      We decorate OperationContexts with a ClientMetadataState here; a ClientMetadataState is a struct containing actual Client metadata and a boolean indicating whether or not the metadata has been set for some particular opCtx.

      When we read the ClientMetadata for an opCtx here, we assume that if the boolean in the ClientMetadataState is set to "true", then the decoration must contain metadata (in fact, we invariant that this is the case).

      However, when we write the ClientMetadata for an opCtx, it's possible we leave it in a state that breaks this invariant (i.e. where the boolean is set to "true" but we don't actually provide any metadata to the decoration). For example, when we set the metadata decoration for an opCtx here, we write "true" to the boolean, but then check two conditions with uassert (one is inside the call to ClientMetadata::readFromMetadata) before actually writing the metadata for the decoration. If these uasserts are hit, the decoration will be left with the boolean set to "true" but no actual metadata set.

      This is a problem if anyone tries to read the metadata later; this can happen in, for example the HandleRequest::completeOperation hook run after the operation fails here where CurOp::completeAndLogOperation will attempt to read the metadata and may hit the aforementioned invariant in ClientMetadata::getForOperation.

        Attachments

          Activity

            People

            Assignee:
            george.wangensteen George Wangensteen
            Reporter:
            george.wangensteen George Wangensteen
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: