{"record":{"id":"b162fd46370a6585","repo":"databendlabs/databend","slug":"internal-error-entered-unreachable-code-b162fd","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/interpreters/hook/refresh_hook.rs","lineNumber":162,"sourceCode":"                                hook_clear_m_cte_temp_table(&query_ctx)?;\n                                hook_vacuum_temp_files(&query_ctx)?;\n                                hook_disk_temp_dir(&query_ctx)?;\n                                Ok(())\n                            },\n                        ));\n\n                        let mut pipelines = build_res.sources_pipelines;\n                        pipelines.push(build_res.main_pipeline);\n\n                        let complete_executor =\n                            PipelineCompleteExecutor::from_pipelines(pipelines, settings)?;\n                        ctx_cloned.set_executor(complete_executor.get_inner())?;\n                        complete_executor.execute().await\n                    } else {\n                        Ok(())\n                    }\n                }\n                _ => unreachable!(),\n            }\n        });\n    }\n\n    let _ = futures::future::try_join_all(tasks).await?;\n    Ok(())\n}\n\nasync fn resolve_refresh_desc(\n    ctx: &Arc<QueryContext>,\n    mut desc: RefreshDesc,\n) -> Result<Option<RefreshDesc>> {\n    let Some((database, table)) = resolve_current_table_name_by_id(\n        ctx,\n        \"refresh\",\n        &desc.catalog,\n        &desc.database,\n        &desc.table,","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/interpreters/hook/refresh_hook.rs#L144-L180","documentation":"do_refresh (src/query/service/src/interpreters/hook/refresh_hook.rs:162) spawns refresh tasks for stream/table objects; the match on the hook's target kind expects only the handled variants and panics via `_ => unreachable!()` for anything else. 'internal error: entered unreachable code' means a refresh hook received a target object kind it was not designed to handle.","triggerScenarios":"execute_refresh_hook runs do_refresh for a hook whose matched object/plan variant falls into the catch-all arm — e.g. a refresh triggered on a table kind or plan variant added later that the hook's match statement does not enumerate.","commonSituations":"Background refresh of streams/materialized views after an upgrade introduced a new object kind; environments with unusual table engines registered where the refresh hook's match was not extended.","solutions":["Upgrade Databend to a version whose refresh hook covers the new object kind","Identify the object triggering the refresh (query log / hook registration) and remove or re-create it with a supported kind","As a code fix, replace the `_ => unreachable!()` arm with a logged no-op or returned internal error naming the unhandled variant","File a bug with the object type and Databend version"],"exampleFix":"// before\n_ => unreachable!(),\n// after\nother => {\n    return Err(ErrorCode::Internal(format!(\n        \"refresh hook: unhandled target variant {:?}\", other\n    )));\n}","handlingStrategy":"retry","validationCode":"// before registering/refreshing, check the object kind is one the hook supports\nlet kind = table.get_table_info().engine();\nif !SUPPORTED_REFRESH_ENGINES.contains(&kind.as_str()) {\n    return Ok(()); // skip refresh for unsupported kinds\n}","typeGuard":"if let HookTarget::Stream(_) | HookTarget::MaterializedView(_) = target { /* handled */ } else { /* skip or log */ }","tryCatchPattern":"// wrap refresh task spawn so one bad object doesn't kill the loop\nfor obj in objects {\n    if let Err(e) = do_refresh(obj).await {\n        log::warn!(\"skip refresh for {:?}: {}\", obj, e);\n    }\n}","preventionTips":["Only create streams/views with engines known to support refresh hooks","After upgrading, re-create streams built on exotic engines","Monitor query-node logs for refresh-hook warnings to catch unsupported objects early"],"tags":["rust","unreachable-panic","hook","refresh"],"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"}