summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_tree_test.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/query/query_planner_tree_test.cpp
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/query/query_planner_tree_test.cpp')
-rw-r--r--src/mongo/db/query/query_planner_tree_test.cpp110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/mongo/db/query/query_planner_tree_test.cpp b/src/mongo/db/query/query_planner_tree_test.cpp
index 5b7055dd720..9d403989792 100644
--- a/src/mongo/db/query/query_planner_tree_test.cpp
+++ b/src/mongo/db/query/query_planner_tree_test.cpp
@@ -32,7 +32,6 @@
#include "mongo/db/query/collation/collator_interface_mock.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/query/query_planner_test_fixture.h"
-#include "mongo/idl/server_parameter_test_util.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -2465,32 +2464,6 @@ TEST_F(QueryPlannerTest, LockstepOrEnumerationSanityCheckTwoChildrenTwoIndexesEa
"{ixscan: {pattern: {a: 1, c: 1}}}}}}}");
}
-TEST_F(QueryPlannerTest, TotalPossibleLockstepOrEnumerationReachesTheOrLimit) {
- params.options =
- QueryPlannerParams::NO_TABLE_SCAN | QueryPlannerParams::ENUMERATE_OR_CHILDREN_LOCKSTEP;
- addIndex(BSON("a" << 1 << "b" << 1));
- addIndex(BSON("a" << 1 << "c" << 1));
-
- BSONArrayBuilder orBuilder;
- // This max number has a value of 65 in order to potentillay triger any overflow of the possible
- // enumeration count, because each predicate in $or has two possible indexes, allowing for 2^65
- // possible enumerations.
- const int maxPredicates = 65;
- for (int i = 0; i < maxPredicates; i++) {
- orBuilder.append(BSON("b" << i << "c" << i));
- }
-
- auto cmd = BSON("find"
- << "testns"
- << "filter" << BSON("a" << 1 << "$or" << orBuilder.arr()));
-
- // Ensure that the query runs fine.
- runQueryAsCommand(cmd);
-
- // internalQueryMaxOrSolutions.load() + 2.
- assertNumSolutions(12U);
-}
-
// Test that we enumerate the expected plans with the special parameter set. In this test we have
// two branches of an $or, each with one possible indexed solution.
TEST_F(QueryPlannerTest, LockstepOrEnumerationSanityCheckTwoChildrenOneIndexEach) {
@@ -2847,89 +2820,6 @@ TEST_F(QueryPlannerTest, LockstepOrEnumerationApplysToEachOrInTree) {
"]}}");
}
-// This test was designed to reproduce SERVER-83091, a case in which an implementation error in the
-// lockstep $or enumeration algorithm could result in an infinite loop. This could happen only if
-// there were nested $or nodes and the inner $or hit the maximum number of plans that it is willing
-// to generate.
-TEST_F(QueryPlannerTest, LockstepOrEnumerationWithNestedOrWhereInnerOrHitsEnumerationLimit) {
- // Disable match expression optimixation, since when enabled it will collapse nested $or nodes
- // into a single $or.
- FailPointEnableBlock failPoint("disableMatchExpressionOptimization");
-
- // The repro depends on the inner $or hitting its enumeration limit. The original problem from
- // SERVER-83091 can be reproduced with a simpler query if we lower the limit on the number of
- // plans that the 'PlanEnumerator' is allowed to generate for any $or node.
- RAIIServerParameterControllerForTest maxOrPlansController(
- "internalQueryEnumerationMaxOrSolutions", 3);
-
- params.options =
- QueryPlannerParams::NO_TABLE_SCAN | QueryPlannerParams::ENUMERATE_OR_CHILDREN_LOCKSTEP;
- addIndex(BSON("a" << 1));
- addIndex(BSON("b" << 1));
- addIndex(BSON("c" << 1));
-
- runQueryAsCommand(fromjson(R"(
- {find: 'testns', filter: {
- $or: [
- {$or: [
- {a: 1, b: 2},
- {a: 3}
- ]},
- {c: 4}
- ]
- }})"));
-
- // There are two plans, the only difference between the two being whether the nested $and
- // {a: 1, b: 2} uses the index on "a" or the index on "b".
- assertNumSolutions(2U);
-
- // Plan using the {a: 1} index for the innermost conjunction.
- assertSolutionExists(R"(
- {
- fetch: {
- node: {
- or: {
- nodes: [
- {
- or: {
- nodes: [
- {fetch: {filter: {b: 2}, node: {ixscan: {pattern: {a: 1}}}}},
- {ixscan: {pattern: {a: 1}}}
- ]
- }
- },
- {ixscan: {pattern: {c: 1}}}
- ]
- }
- }
- }
- }
- )");
-
- // Alternative plan using the {b: 1} index for the innermost conjunction.
- assertSolutionExists(R"(
- {
- fetch: {
- node: {
- or: {
- nodes: [
- {
- or: {
- nodes: [
- {fetch: {filter: {a: 1}, node: {ixscan: {pattern: {b: 1}}}}},
- {ixscan: {pattern: {a: 1}}}
- ]
- }
- },
- {ixscan: {pattern: {c: 1}}}
- ]
- }
- }
- }
- }
- )");
-}
-
TEST_F(QueryPlannerTest, NoOrSolutionsIfMaxOrSolutionsIsZero) {
auto defaultMaxOr = internalQueryEnumerationMaxOrSolutions.load();
ON_BLOCK_EXIT([&] { internalQueryEnumerationMaxOrSolutions.store(defaultMaxOr); });