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

Avoid copying DebugInfoSBE when recovering a plan from the SBE plan cache

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0-rc0
    • Affects Version/s: None
    • Component/s: Query Planning
    • Labels:
      None
    • Fully Compatible
    • QO 2022-04-04
    • 0

      Each entry in the SBE plan cache, in addition to the cached SBE plan itself, holds some debug info that is necessary to correctly populate the logs, system.profile, and so on. At the moment, when a query uses a cached plan, it will copy the debug info out of the cache. I believe that copy happens here.

      Since the debug info is read-only, theoretically all queries using a cache entry could share the same DebugInfoSBE object rather than making their own copy. They can't just keep a reference or raw pointer, because after looking up the entry in the cache, that plan cache entry could subsequently be evicted and the reference/pointer would become invalid. Instead, each query could hold the debug info by std::shared_ptr. That way, the lifetime of the debug info would be extended after the corresponding plan cache entry is destroyed until all queries relying upon the debug info complete.

            Assignee:
            anton.korshunov@mongodb.com Anton Korshunov
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: