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

CanonicalQuery doesn't outlive QuerySolutions in QueryPlannerTest fixture

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.1.6
    • Fix Version/s: 3.2.7, 3.3.5
    • Component/s: Querying
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      Apply the following patch and run the query_planner_geo_test C++ unit test under ASan.

      diff --git a/src/mongo/db/matcher/expression_geo.h b/src/mongo/db/matcher/expression_geo.h
      index 856b310..5631e2e 100644
      --- a/src/mongo/db/matcher/expression_geo.h
      +++ b/src/mongo/db/matcher/expression_geo.h
      @@ -151,7 +151,7 @@ public:
       
           std::string toString() const {
               std::stringstream ss;
      -        ss << " field=" << field;
      +        // ss << " field=" << field;
               ss << " maxdist=" << maxDistance;
               ss << " isNearSphere=" << isNearSphere;
               return ss.str();
      diff --git a/src/mongo/db/query/query_planner_test_fixture.cpp b/src/mongo/db/query/query_planner_test_fixture.cpp
      index 15ecad4..5725bd0 100644
      --- a/src/mongo/db/query/query_planner_test_fixture.cpp
      +++ b/src/mongo/db/query/query_planner_test_fixture.cpp
      @@ -315,13 +315,14 @@ void QueryPlannerTest::dumpSolutions(mongoutils::str::stream& ost) const {
       }
       
       void QueryPlannerTest::assertNumSolutions(size_t expectSolutions) const {
      -    if (getNumSolutions() == expectSolutions) {
      -        return;
      -    }
           mongoutils::str::stream ss;
           ss << "expected " << expectSolutions << " solutions but got " << getNumSolutions()
              << " instead. solutions generated: " << '\n';
           dumpSolutions(ss);
      +    log() << static_cast<std::string>(ss);
      +    if (getNumSolutions() == expectSolutions) {
      +        return;
      +    }
           FAIL(ss);
       }
      
      

      Show
      Apply the following patch and run the query_planner_geo_test C++ unit test under ASan. diff --git a/src/mongo/db/matcher/expression_geo.h b/src/mongo/db/matcher/expression_geo.h index 856b310..5631e2e 100644 --- a/src/mongo/db/matcher/expression_geo.h +++ b/src/mongo/db/matcher/expression_geo.h @@ -151,7 +151,7 @@ public: std::string toString() const { std::stringstream ss; - ss << " field=" << field; + // ss << " field=" << field; ss << " maxdist=" << maxDistance; ss << " isNearSphere=" << isNearSphere; return ss.str(); diff --git a/src/mongo/db/query/query_planner_test_fixture.cpp b/src/mongo/db/query/query_planner_test_fixture.cpp index 15ecad4..5725bd0 100644 --- a/src/mongo/db/query/query_planner_test_fixture.cpp +++ b/src/mongo/db/query/query_planner_test_fixture.cpp @@ -315,13 +315,14 @@ void QueryPlannerTest::dumpSolutions(mongoutils::str::stream& ost) const { } void QueryPlannerTest::assertNumSolutions(size_t expectSolutions) const { - if (getNumSolutions() == expectSolutions) { - return; - } mongoutils::str::stream ss; ss << "expected " << expectSolutions << " solutions but got " << getNumSolutions() << " instead. solutions generated: " << '\n'; dumpSolutions(ss); + log() << static_cast<std::string>(ss); + if (getNumSolutions() == expectSolutions) { + return; + } FAIL(ss); }
    • Sprint:
      Query 13 (04/22/16)

      Description

      The CanonicalQuery is deleted when statusWithCQ goes out of scope in QueryPlannerTest::runInvalidQueryFull(). This was introduced by the changes from SERVER-16889.

      void QueryPlannerTest::runInvalidQueryFull(const BSONObj& query,
                                                 const BSONObj& sort,
                                                 const BSONObj& proj,
                                                 long long skip,
                                                 long long limit,
                                                 const BSONObj& hint,
                                                 const BSONObj& minObj,
                                                 const BSONObj& maxObj,
                                                 bool snapshot) {
          solns.clear();
       
          auto statusWithCQ = CanonicalQuery::canonicalize(nss,
                                                           query,
                                                           sort,
                                                           proj,
                                                           skip,
                                                           limit,
                                                           hint,
                                                           minObj,
                                                           maxObj,
                                                           snapshot,
                                                           false,  // explain
                                                           ExtensionsCallbackNoop());
          ASSERT_OK(statusWithCQ.getStatus());
       
          Status s = QueryPlanner::plan(*statusWithCQ.getValue(), params, &solns.mutableVector());
          ASSERT_NOT_OK(s);
      }
      

        Attachments

        1. asan_output.log
          14 kB
          Max Hirschhorn

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: