databendlabs/databend · error
internal error: entered unreachable code
Error message
internal error: entered unreachable code
What it means
VirtualColumnMeta::physical_type maps a stored physical-type tag constant to a VirtualColumnPhysicalType, and panics with unreachable! on an unknown tag (or expect-fails when the extended type payload is missing). Indicates virtual column metadata on disk uses a tag this binary does not understand, or extended-type metadata is incomplete.
Solutions
- Upgrade to a Databend version that supports the virtual column physical type in the metadata
- Inspect the segment's virtual column meta to identify the unknown tag value
- Rebuild virtual column metadata (re-run virtual column computation) for the affected table
- For developers: replace unreachable! with an error carrying the tag, and validate extended_physical_type at write time
Example fix
// before
_ => unreachable!(),
// after
unknown => Err(ErrorCode::StorageOther(format!(
"unknown virtual column physical type tag {unknown:#x}; upgrade Databend"
))), Defensive patterns
Strategy: fallback
Validate before calling
// rust: check the virtual column tag is recognized before use
const KNOWN_TAGS: &[u8] = &[VIRTUAL_COLUMN_NULLABLE_TYPE, VIRTUAL_COLUMN_TIMESTAMP_TZ_TYPE,
VIRTUAL_COLUMN_INTERVAL_TYPE, VIRTUAL_COLUMN_EXTENDED_TYPE];
assert!(KNOWN_TAGS.contains(&tag), "unknown virtual column tag"); Type guard
fn is_known_virtual_tag(tag: u8) -> bool {
matches!(tag, VIRTUAL_COLUMN_NULLABLE_TYPE | VIRTUAL_COLUMN_TIMESTAMP_TZ_TYPE
| VIRTUAL_COLUMN_INTERVAL_TYPE | VIRTUAL_COLUMN_EXTENDED_TYPE)
} Try / catch
let pty = std::panic::catch_unwind(|| meta.physical_type())
.map_err(|_| "unsupported virtual column physical type; upgrade Databend")?; Prevention
- Keep reader and writer versions in sync for virtual column features
- Recompute virtual columns after upgrades or schema changes
- Validate extended_physical_type is present when writing EXTENDED tags
When it happens
Trigger: Reading a segment containing virtual column metadata whose type tag is none of the known VIRTUAL_COLUMN_*_TYPE constants, or a VIRTUAL_COLUMN_EXTENDED_TYPE entry whose extended_physical_type field is None.
Common situations: Version skew: newer Databend wrote new virtual column physical types (e.g. new extended types) and an older binary reads the segment; partially written/corrupted segment metadata.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- expect tuple type
- internal error: entered unreachable code
- internal error: entered unreachable code
- internal error: entered unreachable code
- {}
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/e89ee3a7204ffcbf.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/storages/common/table_meta/src/meta/v2/segment.rs:260
VIRTUAL_COLUMN_INT16_TYPE => VirtualColumnPhysicalType::Number(NumberDataType::Int16),
VIRTUAL_COLUMN_INT32_TYPE => VirtualColumnPhysicalType::Number(NumberDataType::Int32),
VIRTUAL_COLUMN_FLOAT64_TYPE => {
VirtualColumnPhysicalType::Number(NumberDataType::Float64)
}
VIRTUAL_COLUMN_FLOAT32_TYPE => {
VirtualColumnPhysicalType::Number(NumberDataType::Float32)
}
VIRTUAL_COLUMN_STRING_TYPE => VirtualColumnPhysicalType::String,
VIRTUAL_COLUMN_BINARY_TYPE => VirtualColumnPhysicalType::Binary,
VIRTUAL_COLUMN_DATE_TYPE => VirtualColumnPhysicalType::Date,
VIRTUAL_COLUMN_TIMESTAMP_TYPE => VirtualColumnPhysicalType::Timestamp,
VIRTUAL_COLUMN_TIMESTAMP_TZ_TYPE => VirtualColumnPhysicalType::TimestampTz,
VIRTUAL_COLUMN_INTERVAL_TYPE => VirtualColumnPhysicalType::Interval,
VIRTUAL_COLUMN_EXTENDED_TYPE => self
.extended_physical_type
.clone()
.expect("extended virtual column type is missing"),
_ => unreachable!(),
}
}
}
/// Retained path frequencies for one source variant column in a block.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, FrozenAPI)]
pub struct VirtualColumnPathStatistics {
/// `(segment-local virtual path id, saturated value_count)` pairs.
pub path_counts: Vec<(ColumnId, u32)>,
/// Whether every observed non-direct path for this source is represented in
/// `path_counts`. Direct paths are intentionally represented only by
/// `VirtualBlockMeta.virtual_column_metas`; false means producer-side
/// truncation omitted some non-direct paths.
pub path_statistics_complete: bool,
}
/// Path frequencies for one source variant column before segment-local path ids
/// are assigned. Each pair is `(canonical_path, saturated value_count)`.View on GitHub (pinned to 288d84d76e)