{"record":{"id":"5c848c6f358924a8","repo":"risingwavelabs/risingwave","slug":"magic-number-mismatch-expected-expected-found","errorCode":null,"errorMessage":"Magic number mismatch: expected {expected}, found: {found}","messagePattern":"Magic number mismatch: expected (.+?), found: (.+?)","errorType":"error_code","errorClass":"HummockError","httpStatus":null,"severity":"error","filePath":"src/storage/src/hummock/error.rs","lineNumber":25,"sourceCode":"//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nuse risingwave_object_store::object::ObjectError;\nuse risingwave_pb::id::TableId;\nuse thiserror::Error;\nuse thiserror_ext::AsReport;\nuse tokio::sync::oneshot::error::RecvError;\n\n// TODO(error-handling): should prefer use error types than strings.\n#[derive(Error, thiserror_ext::ReportDebug, thiserror_ext::Arc)]\n#[thiserror_ext(newtype(name = HummockError, backtrace))]\npub enum HummockErrorInner {\n    #[error(\"Magic number mismatch: expected {expected}, found: {found}\")]\n    MagicMismatch { expected: u32, found: u32 },\n    #[error(\"Invalid format version: {0}\")]\n    InvalidFormatVersion(u32),\n    #[error(\"Checksum mismatch: expected {expected}, found: {found}\")]\n    ChecksumMismatch { expected: u64, found: u64 },\n    #[error(\"Invalid block\")]\n    InvalidBlock,\n    #[error(\"Encode error: {0}\")]\n    EncodeError(String),\n    #[error(\"Decode error: {0}\")]\n    DecodeError(String),\n    #[error(\"ObjectStore failed with IO error: {0}\")]\n    ObjectIoError(\n        #[from]\n        #[backtrace]\n        ObjectError,\n    ),\n    #[error(\"Meta error: {0}\")]","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/storage/src/hummock/error.rs#L7-L43","documentation":"HummockErrorInner::MagicMismatch is raised when deserializing Hummock-internal persisted structures (SST/block data, meta files, protobuf payloads with a magic header) whose leading magic number doesn't match the expected constant. It indicates the bytes being read are not the expected file format — wrong file, corruption, or a format/version mismatch.","triggerScenarios":"Reading an SST, block, or other Hummock persisted artifact whose header bytes differ from the expected magic constant (expected vs found are included in the error), typically during compaction, replication, or recovery reads.","commonSituations":"Pointing a node at a data directory from an incompatible RisingWave version; a truncated or corrupted object-store file (partial upload, S3/MinIO issue); hand-copied or mixed data files between clusters.","solutions":["Verify the object/file being read is a genuine Hummock artifact of the expected type — check the 'found' value in the message against known magic constants.","Check whether the file is truncated or corrupted (compare size/checksum with the object store manifest) and re-upload/recover it if possible.","Confirm all RisingWave nodes run a compatible version; incompatible internal formats across versions can change serialization layout.","If corruption is confirmed on the object store, restore from backup or trigger meta to re-generate/rebuild the affected SST (e.g. re-run compaction or rebuild the table from source)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"async fn file_is_valid_hummock_artifact(store: &ObjectStore, path: &str, expected_magic: u32) -> bool {\n    match store.read(path, ..8).await {\n        Ok(bytes) => u32::from_le_bytes(bytes[0..4].try_into().unwrap()) == expected_magic,\n        Err(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match deserialize_artifact(&bytes) {\n    Ok(a) => use(a),\n    Err(e) if matches!(e.root_cause(), HummockErrorInner::MagicMismatch { .. }) => {\n        tracing::error!(\"corrupt/foreign artifact: {e}\");\n        quarantine_and_rebuild(path);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep all RisingWave nodes on a compatible version — internal formats change across major versions.","Enable object-store integrity checks (checksums) to catch partial uploads early.","Never copy data files between clusters manually; use backup/restore tooling.","Alert on MagicMismatch during recovery — it usually means corrupted or truncated SSTs on the object store."],"tags":["rust","hummock","storage","corruption","serialization"],"backgroundTag":"checksum-mismatch","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}