{"record":{"id":"3cc7dd3e7482b25d","repo":"databendlabs/databend","slug":"logic-error-cannot-change-priority-for-querypipel","errorCode":null,"errorMessage":"Logic error: cannot change priority for QueryPipelineExecutor","messagePattern":"Logic error: cannot change priority for QueryPipelineExecutor","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/pipelines/executor/pipeline_executor.rs","lineNumber":313,"sourceCode":"                    .fetch_profiling(Some(v.settings.executor_node_id.clone())),\n                false => v.graph.fetch_profiling(None),\n            },\n        }\n    }\n\n    pub fn fetch_perf_counters(&self) -> NodePerfCounters {\n        match self {\n            PipelineExecutor::QueryPipelineExecutor(executor) => {\n                executor.graph.fetch_perf_counters()\n            }\n            PipelineExecutor::QueriesPipelineExecutor(v) => v.graph.fetch_perf_counters(),\n        }\n    }\n\n    pub fn change_priority(&self, priority: u8) {\n        match self {\n            PipelineExecutor::QueryPipelineExecutor(_) => {\n                unreachable!(\"Logic error: cannot change priority for QueryPipelineExecutor\")\n            }\n            PipelineExecutor::QueriesPipelineExecutor(query_wrapper) => {\n                query_wrapper.graph.change_priority(priority as u64);\n            }\n        }\n    }\n\n    pub fn get_query_execution_stats(&self) -> ExecutorStatsSnapshot {\n        match self {\n            PipelineExecutor::QueryPipelineExecutor(executor) => {\n                executor.get_query_execution_stats()\n            }\n            PipelineExecutor::QueriesPipelineExecutor(query_wrapper) => {\n                query_wrapper.graph.get_query_execution_stats()\n            }\n        }\n    }\n}","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/pipelines/executor/pipeline_executor.rs#L295-L331","documentation":"`PipelineExecutor::change_priority` panics with an explicit `unreachable!(\"Logic error: cannot change priority for QueryPipelineExecutor\")` when priority adjustment is requested on a plain `QueryPipelineExecutor`. Priority changes are only supported by `QueriesPipelineExecutor` (the multi-query executor whose scheduling graph supports re-prioritization); the single-query executor has no such mechanism.","triggerScenarios":"Calling `executor.change_priority(p)` on an executor obtained as `PipelineExecutor::QueryPipelineExecutor(_)` — e.g., client/server code adjusting query priority at runtime without checking which executor variant is active.","commonSituations":"Management APIs or session code that unconditionally calls change_priority; deployments running single-query executors while tooling assumes the multi-query scheduler; API version changes introducing the QueryPipelineExecutor variant.","solutions":["Before calling change_priority, inspect the executor variant (match on PipelineExecutor) and skip or log a warning for QueryPipelineExecutor","Route priority changes only through QueriesPipelineExecutor-backed sessions where the scheduling graph exists","Update calling code to treat priority change as best-effort: attempt it and handle unsupported executors gracefully instead of panicking","If runtime priority matters for your workload, configure the deployment to use the multi-query executor"],"exampleFix":"// before\nexecutor.change_priority(priority); // panics for QueryPipelineExecutor\n// after\nif let PipelineExecutor::QueriesPipelineExecutor(_) = &executor {\n    executor.change_priority(priority);\n}","handlingStrategy":"validation","validationCode":"// Only adjust priority on executors that support it\nif let PipelineExecutor::QueriesPipelineExecutor(_) = &executor {\n    executor.change_priority(priority);\n}","typeGuard":"fn supports_priority(e: &PipelineExecutor) -> bool {\n    matches!(e, PipelineExecutor::QueriesPipelineExecutor(_))\n}","tryCatchPattern":"catch_unwind around executor calls that may change priority; log and continue instead of crashing the session","preventionTips":["Check the executor variant before calling change_priority","Expose change_priority only on the QueriesPipelineExecutor type so misuse is a compile error","Treat priority changes as best-effort in management APIs","Add an integration test that calls change_priority on both executor variants"],"tags":["rust","panic","executor","priority","scheduling","internal-invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}