Forbid direct query knob access

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc1
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • Fully Compatible
    • QE 2026-07-20
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Query knob server parameters (the generated AtomicWord globals in query_execution_knobs_gen.h, query_optimization_knobs_gen.h) can currently be read directly from anywhere, bypassing QueryKnobConfiguration and its per-operation snapshot/QuerySettings-override semantics. We want a structural guarantee that all per-query knob reads go through QueryKnobConfiguration.

      Approach

      Instead of the #error-based include protector (as used by stage_memory_limit_knobs/knobs_protector.h), use the module visibility system (modules_poc, enforced as a hard failure by the lint_modules task in the merge queue). This bans use rather than inclusion, so the descriptor headers keep deducing knob value types from the globals and no header restructuring, IDL splitting, or X-macro changes are needed.

      • Define a query.knobs submodule in modules_poc/modules.yaml covering query_knobs/, the knob IDLs, and the knob descriptor tables. Being a submodule of query means module-private declarations are inaccessible even to the rest of the query module.
      • Public API: QueryKnobConfiguration, the QueryKnob/QueryKnobId handle types, QueryKnobValue/DeleteQueryKnobOverride, and the knob enums (mod_visibility: pub).
      • Parent-private (query-module-only) plumbing for the trusted collaborators (query settings, $listQueryKnobs): QueryKnobSnapshot/Builder/Cache, QueryKnobRegistry, WithOnUpdateHook, and the knob descriptor handles.
      • Knob server parameter globals default to module-private via file-wide mod_visibility: private in the knob IDLs. Parameters with existing direct readers are individually marked needs_replacement (the migration burn-down list, ~130 parameters). Process-level settings that are not per-query knobs (enableComputeMode, externalPipeDir) are marked public.

      Follow-up work

      • Migrate the needs_replacement readers to QueryKnobConfiguration and flip the parameters to private, per IDL file.
      • Move the enum server parameter implementations (framework_control.cpp, plan_ranker_mode.cpp, ...) under query_knobs/ so they are in-module.
      • Extend the same treatment to query_integration_knobs.idl and stage_memory_limit_knobs.

            Assignee:
            Catalin Sumanaru
            Reporter:
            Catalin Sumanaru
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: