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

Query subsystem public API should use std::unique_ptr for ownership transfer

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1.6
    • Component/s: Querying
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Quint Iteration 6

      Description

      The main entry methods in the query subsystem transfer ownership of heap-allocated objects through raw pointers, which is error-prone. These methods should use std::unique_ptr instead. Partial list follows:

      • CanonicalQuery::canonicalize(). Caller receives ownership of a CanonicalQuery.
      • LiteParsedQuery::make(). Caller receives ownership of a LiteParsedQuery.
      • StatusWithMatchExpression replace MatchExpression* with unique_ptr<MatchExpression>
      • MatchExpression::shallowClone(). Caller receives ownership of a MatchExpression.
      • PlanExecutor::make(). Caller releases ownership of a WorkingSet, a PlanStage, a CanonicalQuery and a QuerySolution, and receives ownership of a PlanExecutor.
      • getExecutor(). Caller releases ownership of a CanonicalQuery, and receives ownership of a PlanExecutor (other public methods in get_executor.cpp can follow suit).
      • PlanExecutor::getStats(). Caller receives ownership of a PlanStageStats.

      Linking a few tickets describing ownership-related memory leaks induced by incorrect use of the above (and related) methods.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: