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

replanReason is incorrectly omitted from logs when replanning a query with $group/$lookup pushed down to SBE

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 6.1.0-rc0
    • None
    • None
    • None
    • Fully Compatible
    • ALL
    • QE 2022-04-18

    Description

      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.

      Attachments

        Activity

          People

            yoonsoo.kim@mongodb.com Yoon Soo Kim
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: