{"record":{"id":"9eb31cbf01a81cbe","repo":"databendlabs/databend","slug":"internal-error-entered-unreachable-code-9eb31c","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/storages/delta/src/table_source.rs","lineNumber":198,"sourceCode":"            match &part.data {\n                ParquetPart::File(f) => {\n                    let partition_fields = self\n                        .partition_fields\n                        .iter()\n                        .cloned()\n                        .zip(part.partition_values.iter().cloned())\n                        .collect::<Vec<_>>();\n                    self.partition_block_scalars = partition_fields\n                        .iter()\n                        .map(|(f, v)| (f.data_type().into(), v.clone()))\n                        .collect::<Vec<_>>();\n                    let stream = self\n                        .parquet_reader\n                        .prepare_data_stream(&f.file, f.compressed_size, Some(&partition_fields))\n                        .await?;\n                    self.stream = Some(stream);\n                }\n                _ => unreachable!(),\n            }\n        } else {\n            self.is_finished = true;\n        }\n\n        Ok(())\n    }\n}\n\nfn check_block_schema(schema: &DataSchema, mut block: DataBlock) -> Result<DataBlock> {\n    // Check if the schema of the data block is matched with the schema of the table.\n    if block.num_columns() != schema.num_fields() {\n        return Err(ErrorCode::TableSchemaMismatch(format!(\n            \"Data schema mismatched. Data columns length: {}, schema fields length: {}\",\n            block.num_columns(),\n            schema.num_fields()\n        )));\n    }","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/storages/delta/src/table_source.rs#L180-L216","documentation":"In the Delta Lake table source, async_process advances the read state machine and panics with unreachable! when it encounters an unexpected state variant. The state machine expects only the prepared-partition-file state at that point; anything else means internal state got out of sync.","triggerScenarios":"Reading a Delta table when the processor's internal state enum is in a variant other than the expected one when async_process runs — typically due to a poll/reschedule ordering bug or a previous failed transition.","commonSituations":"Delta table scans under async backpressure or processor rescheduling; concurrency bugs in the pipeline state machine; exceptions interleaved with state transitions.","solutions":["Re-run the query; transient scheduling issues may not reproduce","Simplify the query plan (remove filters/partition pruning) to avoid the code path and confirm it's a state-machine bug","Collect the query profile/trace and file a Databend bug with the plan","Upgrade Databend — pipeline state-machine fixes land regularly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// catch pipeline panic around Delta scan and retry once\nmatch execute_delta_scan(query).await {\n    Err(e) if is_panic_unreachable(&e) => retry_with_simplified_plan(query).await,\n    other => other,\n}","preventionTips":["Report reproducing Delta scans to maintainers — this is an internal state bug","Avoid mixing concurrent mutations of the same Delta source processor","Keep Databend updated; state-machine fixes are released frequently"],"tags":["rust","panic","unreachable","delta-lake","state-machine"],"backgroundTag":"invalid-state-transition","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"}