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

FindCmd checks the bool value of an optional incorrectly

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • Fully Compatible
    • ALL
    • QE 2023-02-06

      The comment here:

                  // Set the namespace if a collection was found, as opposed to nothing or a view.
                  if (ctx) {
                      query_request_helper::refreshNSS(ctx->getNss(), findCommand.get());
                  }
      

      make it seem like refreshNss should only be evaluated if the collection exists in ctx, which is of type boost::optional<AutoGetCollectionForReadCommandMaybeLockFree>. But it's actually only checking whether the optional is populated. But the optional is always populated so refreshNss always runs.

      It should probably be if (*ctx) or the code should be rewritten to not use an optional, but that might be difficult since we manually reset the optional later on.

            Assignee:
            adi.agrawal@mongodb.com Adi Agrawal
            Reporter:
            matthew.saltz@mongodb.com Matthew Saltz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: