Skip to content

Commit

Permalink
SERVER-83220 Introduce MultiCollectionRouter to correctly handle seco…
Browse files Browse the repository at this point in the history
…ndary collection shard versions for SBE $lookup pushdown

Co-authored-by: Jordi Serra Torrens <jordi.serra-torrens@mongodb.com>
GitOrigin-RevId: a63db2a047e3b654820ac085a1207488b6418cd2
  • Loading branch information
2 people authored and MongoDB Bot committed Feb 3, 2024
1 parent b2297e0 commit 3ca96ff
Show file tree
Hide file tree
Showing 18 changed files with 771 additions and 260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ selector:
- jstests/aggregation/use_query_projection.js
- jstests/aggregation/use_query_sort.js

# TODO: SERVER-83220 (Failing due to incorrect pushdown of $lookup for non-collocated collections).
# Reenable:
- jstests/aggregation/sources/facet/inner_lookup.js
# These tests are written such that, after we check the engine being used and the colocation of
# the involved collections, we drop and recreate our collections for each test case. Given that
# this suite creates unsplittable collections on random shards and we cannot reliably check the
# colocation of collections in these tests, this means that these tests are incompatible with
# this suite as written.
# TODO SERVER-83351: Rewrite these tests to be compatible with this suite.
- jstests/aggregation/sources/lookup/lookup_equijoin_semantics_inlj.js
- jstests/aggregation/sources/lookup/lookup_equijoin_semantics_nlj.js
- jstests/aggregation/sources/lookup/lookup_equijoin_semantics_hj.js

# TODO SERVER-85965: These tests currently fail because we do not track the collation of
# unsplittable collections in the sharding catalog, and we do not lookup the collation from the
# primary shard. Re-enable these tests once we either track this information, or look it up.
- jstests/aggregation/sources/lookup/lookup_collation.js
- jstests/aggregation/sources/lookup/lookup_foreign_collation.js
- jstests/aggregation/dbref.js

# TODO: SERVER-83351 (failing due to incorrect explain expectations). Reenable:
- jstests/aggregation/explain_writing_aggs.js
Expand Down
13 changes: 13 additions & 0 deletions jstests/core/views/views_validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ makeView("v0", "ok", [makeFacet("v1")], ErrorCodes.ViewDepthLimitExceeded);
makeView("v0", "ok", [makeUnion("v1")], ErrorCodes.ViewDepthLimitExceeded);

// Test that querying a view that descends more than 20 views will fail.

// If this is a sharded cluster, we run the initial aggregate once. If this doesn't have the
// necessary routing information to detect that the view is invalid, this will throw a StaleConfig
// error instead. In doing so it will obtain the routing information for 10 of our views (one on
// each attempt), which will allow the subsequent aggregates to discover that the view chain is 20
// deep and fail as expected.
// TODO SERVER-85941: This ticket aims to prevent needing an extra aggregate to get some of the
// routing information.
if (db.getMongo().isMongos()) {
assert.commandFailedWithCode(
viewsDb.runCommand({aggregate: "v10", pipeline: [makeUnion("v1")], cursor: {}}),
[ErrorCodes.ViewDepthLimitExceeded, ErrorCodes.StaleConfig]);
}
assert.commandFailedWithCode(
viewsDb.runCommand({aggregate: "v10", pipeline: [makeUnion("v1")], cursor: {}}),
ErrorCodes.ViewDepthLimitExceeded);
Expand Down
9 changes: 7 additions & 2 deletions jstests/libs/shard_targeting_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export class ShardTargetingTest {
const split = explain.splitPipeline;
assert(split.hasOwnProperty("mergerPart"), explain);
const mergerPart = split.mergerPart;
assert(
expectedMergingStages,
"Should have specified merging stages for test case if 'expectedMergingShard' was specified" +
tojson(explain));
assert(expectedMergingStages, explain);
this._assertExpectedStages(expectedMergingStages, mergerPart, explain);
} else {
Expand All @@ -117,10 +121,11 @@ export class ShardTargetingTest {
this._assertExpectedStages(expectedShardStages, stages, explain);
}

const stage = getAggPlanStage(shard, "EQ_LOOKUP", true /* useQueryPlannerSection */);
if (assertSBELookupPushdown) {
const stage =
getAggPlanStage(shard, "EQ_LOOKUP", true /* useQueryPlannerSection */);
assert.neq(stage, null, shard);
} else {
assert.eq(stage, null, shard);
}
}
}
Expand Down
Loading

0 comments on commit 3ca96ff

Please sign in to comment.