{"record":{"id":"a577dac47a7574bb","repo":"databendlabs/databend","slug":"queryinfo-is-none","errorCode":null,"errorMessage":"QueryInfo is none","messagePattern":"QueryInfo is none","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/servers/flight/v1/exchange/exchange_manager.rs","lineNumber":1007,"sourceCode":"        }\n    }\n\n    pub fn get_fragment_source(\n        &self,\n        query_id: &str,\n        fragment_id: usize,\n        injector: Arc<dyn ExchangeInjector>,\n    ) -> Result<PipelineBuildResult> {\n        let queries_coordinator_guard = self.queries_coordinator.lock();\n        let queries_coordinator = unsafe { &mut *queries_coordinator_guard.deref().get() };\n\n        match queries_coordinator.get_mut(query_id) {\n            None => Err(ErrorCode::Internal(\"Query not exists.\")),\n            Some(query_coordinator) => {\n                let query_ctx = query_coordinator\n                    .info\n                    .as_ref()\n                    .expect(\"QueryInfo is none\")\n                    .query_ctx\n                    .clone();\n\n                query_coordinator.subscribe_fragment(&query_ctx, fragment_id, injector)\n            }\n        }\n    }\n}\n\nstruct QueryInfo {\n    query_id: String,\n    started: AtomicBool,\n    current_executor: String,\n    query_ctx: Arc<QueryContext>,\n    remove_leak_query_worker: Option<JoinHandle<()>>,\n    query_executor: Option<Arc<PipelineCompleteExecutor>>,\n}\n","sourceCodeStart":989,"sourceCodeEnd":1025,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/servers/flight/v1/exchange/exchange_manager.rs#L989-L1025","documentation":"`get_fragment_source` looks up the query coordinator by id and expects its `info` (holding query_ctx) to exist, panicking with `expect(\"QueryInfo is none\")` otherwise. The invariant: any coordinator visible in the map has been fully initialized with QueryInfo before fragments are subscribed.","triggerScenarios":"A fragment source request (e.g. `get_fragment_source` during pipeline execution) arrives for a query whose coordinator was registered but whose QueryInfo/context was not yet set or was already removed — a setup/teardown race on the same node.","commonSituations":"Query cancelled/timed out while fragments still request sources; init_query_env failed partway after registration; retry or duplicate fragment requests arriving after coordinator teardown.","solutions":["Check whether the query was concurrently cancelled or its init failed; look for the earlier error in logs for the same query id.","Guard the request path: return `ErrorCode::Internal(\"Query info not ready\")` (or query-not-exists) instead of panicking when info is None.","Ensure init_query_env sets info before the coordinator becomes visible to fragment requests (ordering fix).","Retry the query on a healthy node if the state resulted from a transient failure."],"exampleFix":"// before\n.expect(\"QueryInfo is none\")\n// after\n.ok_or_else(|| ErrorCode::Internal(format!(\"QueryInfo is none for query {query_id}\")))?","handlingStrategy":"try-catch","validationCode":"// caller-side: confirm query still exists and is initialized before requesting fragments\n// match coordinator.info { None => return Err(...), Some(_) => proceed }","typeGuard":"fn coordinator_ready(c: &QueryCoordinator) -> bool { c.info.is_some() }","tryCatchPattern":"let info = query_coordinator.info.as_ref().ok_or_else(||\n    ErrorCode::Internal(format!(\"query {query_id} not initialized\")))?;","preventionTips":["Ensure info is set before the coordinator becomes discoverable","Handle query cancellation before fragment source requests","Add integration tests for cancel/init races"],"tags":["rust","panic","query-lifecycle","distributed-query"],"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"}