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

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • v8.1, 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
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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
            Reporter:
            Ivan Fefer
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: