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

MutableDocument::hasField() can return false positives

    XMLWordPrintableJSON

Details

    • Fully Compatible
    • ALL
    • Query 2018-09-24

    Description

      In SERVER-36100, charlie.swanson and I noticed that MutableDocument::hasField() tests for existence by asking its underlying storage if it has the field in its hash table. However, this will be incorrect if the field used to exist but has cleared (for example, by a $project earlier in the pipeline).

      We both used a static analysis tool and believed there to be no callers of this function, but when I attempted to remove it I found there exists a single caller:

      cluster_aggregate.cpp

      185
          if (opCtx->getTxnNumber()) {
      186
              invariant(!cmdForShards.hasField(OperationSessionInfo::kTxnNumberFieldName));
      187
              cmdForShards[OperationSessionInfo::kTxnNumberFieldName] =
      188
                  Value(static_cast<long long>(*opCtx->getTxnNumber()));
      189
          }
      

      As part of this ticket we should either fix the function or delete it and replace the caller's usage with an equivalent check.

      Attachments

        Activity

          People

            charlie.swanson@mongodb.com Charlie Swanson
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: