databendlabs/databend · error

Logic error: cannot change priority for…

Error message

Logic error: cannot change priority for QueryPipelineExecutor

What it means

`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.

Solutions

  1. Before calling change_priority, inspect the executor variant (match on PipelineExecutor) and skip or log a warning for QueryPipelineExecutor
  2. Route priority changes only through QueriesPipelineExecutor-backed sessions where the scheduling graph exists
  3. Update calling code to treat priority change as best-effort: attempt it and handle unsupported executors gracefully instead of panicking
  4. If runtime priority matters for your workload, configure the deployment to use the multi-query executor

Example fix

// before
executor.change_priority(priority); // panics for QueryPipelineExecutor
// after
if let PipelineExecutor::QueriesPipelineExecutor(_) = &executor {
    executor.change_priority(priority);
}
Defensive patterns

Strategy: validation

Validate before calling

// Only adjust priority on executors that support it
if let PipelineExecutor::QueriesPipelineExecutor(_) = &executor {
    executor.change_priority(priority);
}

Type guard

fn supports_priority(e: &PipelineExecutor) -> bool {
    matches!(e, PipelineExecutor::QueriesPipelineExecutor(_))
}

Try / catch

catch_unwind around executor calls that may change priority; log and continue instead of crashing the session

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/3cc7dd3e7482b25d. Report an issue: GitHub.

Appendix: source

Thrown at src/query/service/src/pipelines/executor/pipeline_executor.rs:313

                    .fetch_profiling(Some(v.settings.executor_node_id.clone())),
                false => v.graph.fetch_profiling(None),
            },
        }
    }

    pub fn fetch_perf_counters(&self) -> NodePerfCounters {
        match self {
            PipelineExecutor::QueryPipelineExecutor(executor) => {
                executor.graph.fetch_perf_counters()
            }
            PipelineExecutor::QueriesPipelineExecutor(v) => v.graph.fetch_perf_counters(),
        }
    }

    pub fn change_priority(&self, priority: u8) {
        match self {
            PipelineExecutor::QueryPipelineExecutor(_) => {
                unreachable!("Logic error: cannot change priority for QueryPipelineExecutor")
            }
            PipelineExecutor::QueriesPipelineExecutor(query_wrapper) => {
                query_wrapper.graph.change_priority(priority as u64);
            }
        }
    }

    pub fn get_query_execution_stats(&self) -> ExecutorStatsSnapshot {
        match self {
            PipelineExecutor::QueryPipelineExecutor(executor) => {
                executor.get_query_execution_stats()
            }
            PipelineExecutor::QueriesPipelineExecutor(query_wrapper) => {
                query_wrapper.graph.get_query_execution_stats()
            }
        }
    }
}

View on GitHub (pinned to 288d84d76e)