databendlabs/databend · error

expect query info

Error message

expect query info

What it means

`remove_if_leak_query` inspects a registered QueryCoordinator's `info` and panics with `expect("expect query info")` if `info` is None. The invariant is that a coordinator stored in the map always carries QueryInfo; firing means the entry was inserted without info or info was taken/cleared concurrently.

Solutions

  1. Check the logs for the query id and whether set_ctx/prepare_pipeline ran before the sweeper; fix any early-abort path that registers a coordinator without info.
  2. Make the sweeper resilient: treat `info == None` as a leak candidate (or skip) instead of panicking.
  3. Reduce the race window by assigning QueryInfo atomically with coordinator insertion.
  4. Upgrade to a version where leak-sweep handling of uninitialized coordinators is hardened.

Example fix

// before
let info = may_leak_query.info.as_ref().expect("expect query info");
// after
let Some(info) = may_leak_query.info.as_ref() else { return Some(query_id); };
Defensive patterns

Strategy: type-guard

Validate before calling

// guard before inspecting leak candidates
if may_leak_query.info.is_none() { /* treat as leak or skip */ }

Type guard

fn has_query_info(c: &QueryCoordinator) -> bool { c.info.is_some() }

Try / catch

// tolerate missing info in the sweeper
let Some(info) = may_leak_query.info.as_ref() else { return Some(query_id) };

Prevention

When it happens

Trigger: Leak-detection cleanup iterates `queries_coordinator` and finds an entry whose `info` was never set (registration raced with info assignment) or was already consumed, while `remove_if_leak_query` runs.

Common situations: A query failing/cancelling between coordinator registration and `set_ctx`/info assignment while the leak sweeper runs; manual insertion paths or version-skewed nodes sharing state.

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/b357089d5dde68d8. Report an issue: GitHub.

Appendix: source

Thrown at src/query/service/src/servers/flight/v1/exchange/exchange_manager.rs:516

                };

                return Ok(());
            }
        }

        // do nothing
        Ok(())
    }

    fn remove_if_leak_query(&self, query_id: String) {
        let leak_query_id = {
            let queries_coordinator_guard = self.queries_coordinator.lock();
            let queries_coordinator = unsafe { &mut *queries_coordinator_guard.deref().get() };

            match queries_coordinator.get(&query_id) {
                None => None,
                Some(may_leak_query) => {
                    let info = may_leak_query.info.as_ref().expect("expect query info");
                    match info.started.load(Ordering::SeqCst) {
                        true => None,
                        false => Some(query_id),
                    }
                }
            }
        };

        if let Some(query_id) = leak_query_id {
            warn!(
                "Query {} cannot start command while in 180 seconds",
                query_id
            );
            self.on_finished_query(
                &query_id,
                Some(ErrorCode::Internal(format!(
                    "Query {} cannot start command while in 180 seconds",
                    query_id

View on GitHub (pinned to 288d84d76e)