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

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.1.6
    • Querying
    • None
    • Fully Compatible
    • 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

              qingyang.chen Qingyang Chen
              rassi J Rassi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: