|
When a replan occurs, a string field called "replanReason" is supposed to appear in the log and in system.profile. This is broken if there is a $group or $lookup pushed down to SBE. You can reproduce this with the same repro script that I wrote for related ticket SERVER-65197.
After some digging, I was able to spot that the problem occurs here:
https://github.com/mongodb/mongo/blob/e30ac62b20a58a26087b5eb3c5ebc55da7f15d17/src/mongo/db/query/sbe_multi_planner.cpp#L148-L153
Imagine that a replan occurs, and the system uses the SBE multi-planner to select a new plan. The "replanReason" string is present in PlanStageData::replanReason, and each candidate plan has an associated PlanStageData object.
When a $group or $lookup has been pushed down, the multi-planner selects a plan and then creates an entirely new SBE tree after calling extendWithAggPipeline(). This process currently drops the old PlanStageData object and creates a fresh one. As a result, we discard the value of "replanReason". When the downstream code responsible for displaying "replanReason" in the logs and profile executes, it finds no value and therefore displays nothing.
|