{"record":{"id":"3843c7445a0e4e69","repo":"databendlabs/databend","slug":"e-3843c7","errorCode":null,"errorMessage":"e","messagePattern":"e","errorType":"exception","errorClass":"InvalidData","httpStatus":null,"severity":"error","filePath":"src/query/storages/common/table_meta/src/meta/format.rs","lineNumber":77,"sourceCode":"                \"unsupported compression: {}\",\n                other\n            ))),\n        }\n    }\n}\n\npub fn compress(compression: &MetaCompression, data: Vec<u8>) -> Result<Vec<u8>> {\n    match compression {\n        MetaCompression::None => Ok(data),\n        MetaCompression::Zstd => {\n            let mut encoder = ZstdEncoder::new(Vec::new(), 0)?;\n            encoder.write_all(&data)?;\n            Ok(encoder.finish()?)\n        }\n        #[cfg(feature = \"dev\")]\n        MetaCompression::Snappy => Ok(SnapEncoder::new()\n            .compress_vec(&data)\n            .map_err(|e| Error::new(ErrorKind::InvalidData, e))?),\n        #[cfg(not(feature = \"dev\"))]\n        _ => Err(ErrorCode::UnknownFormat(format!(\n            \"unsupported compression: {:?}\",\n            compression\n        ))),\n    }\n}\n\npub fn decompress(compression: &MetaCompression, data: Vec<u8>) -> Result<Vec<u8>> {\n    match compression {\n        MetaCompression::None => Ok(data),\n        MetaCompression::Zstd => {\n            let mut decoder = ZstdDecoder::new(&data[..])?;\n            let mut decompressed_data = Vec::new();\n            decoder\n                .read_to_end(&mut decompressed_data)\n                .map_err(|e| Error::new(ErrorKind::InvalidData, e))?;\n            Ok(decompressed_data)","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/storages/common/table_meta/src/meta/format.rs#L59-L95","documentation":"During metadata compression with MetaCompression::Snappy when the 'dev' feature is disabled, compress() deliberately returns ErrorCode::UnknownFormat('unsupported compression: {:?}') because the Snappy path is compiled out. Any caller (RawBlockMeta, encode_column_hll) writing table metadata compressed with Snappy in a non-dev build will fail. It is a build-feature/config mismatch, not a data corruption issue.","triggerScenarios":"Calling compress() with compression=MetaCompression::Snappy in a binary built without the 'dev' feature (the #[cfg(not(feature = \"dev\"))] fallback arm). Any read path that persisted Snappy-compressed meta with a dev build and is then consumed by a non-dev build.","commonSituations":"Mixing dev and release builds against the same table data; a stored meta file whose header records Snappy while the running binary lacks the feature; manually setting MetaCompression::Snappy in config/code of a production build.","solutions":["Rebuild the binary with the 'dev' feature enabled so the Snappy encoder is compiled in","Rewrite existing metadata with MetaCompression::Zstd or MetaCompression::None using a dev build, then use those in production","Find and fix the code/config path that selects MetaCompression::Snappy in non-dev deployments"],"exampleFix":"// before\nMetaCompression::Snappy\n// after\nMetaCompression::Zstd  // supported in all builds","handlingStrategy":"validation","validationCode":"if !cfg!(feature = \"dev\") && *compression == MetaCompression::Snappy {\n    return Err(ErrorCode::UnknownFormat(\"snappy meta compression requires feature 'dev'\".into()));\n}","typeGuard":"fn is_snappy(c: &MetaCompression) -> bool { matches!(c, MetaCompression::Snappy) }","tryCatchPattern":"match compress(encoding, &data) {\n    Err(e) if e.message().contains(\"unsupported compression\") => fallback_to_zstd(&data),\n    other => other,\n}","preventionTips":["Never persist metadata with MetaCompression::Snappy in builds without the 'dev' feature","Default configs to Zstd, which is available in all feature combinations","Add a startup assertion that the configured compression is supported by the current build"],"tags":["compression","feature-gate","rust","serialization"],"backgroundTag":"feature-not-enabled","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"}