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

Trigger replanning by throwing an exception, instead of creating another planner

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • v8.0
    • QO 2024-04-01, QO 2024-04-15, QO 2024-04-29, QO 2024-05-13, QO 2024-05-27, QO 2024-06-10, QO 2024-06-24, QO 2024-07-08, QO 2024-07-22, QO 2024-08-05, QO 2024-08-19, QO 2024-09-02
    • 144

      Historically, we create another planner inside already existing one to replan cached plan:

      https://github.com/mongodb/mongo/blob/2759b1aee8d46ad7807aebd7bbff08a6cf318c5d/src/mongo/db/exec/cached_plan.cpp#L265

      https://github.com/mongodb/mongo/blob/2759b1aee8d46ad7807aebd7bbff08a6cf318c5d/src/mongo/db/query/sbe_cached_solution_planner.cpp#L379

      We were unable to just throw an exception, because at this point we already owned CanonicalQuery and throwing an exception would cause us to destroy it.

      However, now that we can throw exceptions to restart planning without query settings, we can do the same for replanning: instead of having custom and complex replanning logic, let's just invalidate cache entry and restart query planning process by throwing ReplanningException with replanReason field.

      This assumes that replanning is pretty exception thing to happen.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ivan.fefer@mongodb.com Ivan Fefer
            Votes:
            1 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: