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

MutableDocument::hasField() can return false positives

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

      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
          if (opCtx->getTxnNumber()) {
              invariant(!cmdForShards.hasField(OperationSessionInfo::kTxnNumberFieldName));
              cmdForShards[OperationSessionInfo::kTxnNumberFieldName] =
                  Value(static_cast<long long>(*opCtx->getTxnNumber()));
          }
      

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

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

              Created:
              Updated:
              Resolved: