Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
-
None
-
Fully Compatible
-
ALL
-
v6.0
-
QE 2022-06-27, QE 2022-07-11, QE 2022-07-25, QE 2022-08-08
-
10
Description
index_stats.js is failing on sharding_jscore_passthrough_last_continuous and sharding_jscore_passthrough_last_lts test suites because of unreliable feature detection logic of checkSBEEnabled().
Instead of relying on checkSBEEnabled(), better to detect feature availability based on explain result for index_stats.js.
Proposed changes:
// Figure out whether the $lookup with foreign field index is pushed down to the SBE as INLJ.
|
//
|
// This function assumes that 'pipeline' has a $lookup stage.
|
//
|
// 'checkSBEEnabled(..., featureFlag) does not work very well for a mixed version cluster because
|
// when it detects the first shard that the 'featureFlag' is turned on, it just returns true but
|
// in a mixed version cluster, some shard may not support such 'featureFlag'. So, need to check
|
// whether the $lookup is pushed down or not based on 'explain' result.
|
var isLookupPushedDownToSBEAsINLJ = function(coll, pipeline) {
|
const explainDoc = |
db.runCommand({aggregate: coll.getName(), pipeline: pipeline, explain: true}); |
// If $lookup is pushed down to the SBE, 'explainVersion' must be "2". |
if (explainDoc.explainVersion != "2") { |
return false; |
}
|
const eqLookupStage = getPlanStage(explainDoc, "EQ_LOOKUP"); |
// If $lookup is pushed down to the SBE, EQ_LOOKUP stage must exist. |
if (!eqLookupStage) { |
return false; |
}
|
return eqLookupStage.strategy == "IndexedLoopJoin"; |
};
|
...
if (!isLookupPushedDownToSBEAsINLJ(col, pipeline)) {
|
assert.eq(2,
|
getUsageCount("_id_", foreignCollection),
|
"Expected each lookup to be tracked as an index use");
|
} else {
|
assert.eq(1,
|
getUsageCount("_id_", foreignCollection),
|
"Expected the index join lookup to be tracked as a single index use");
|
}
|