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

CanonicalQuery doesn't outlive QuerySolutions in QueryPlannerTest fixture

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.7, 3.3.5
    • Affects Version/s: 3.1.6
    • Component/s: Querying
    • Fully Compatible
    • ALL
    • Hide

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

      Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      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. Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml 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); }
    • Query 13 (04/22/16)

      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);
      }
      

        1. asan_output.log
          14 kB
          Max Hirschhorn

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: