{"record":{"id":"b7d17f0d5069352b","repo":"microsoft/FASTER","slug":"unexpected-entry-type","errorCode":null,"errorMessage":"Unexpected entry type","messagePattern":"Unexpected entry type","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"critical","filePath":"cs/src/core/Allocator/AllocatorBase.cs","lineNumber":608,"sourceCode":"                        {\n                            // Only read metadata if we need to stop at a specific version\n                            var metadata = new byte[entryLength];\n                            unsafe\n                            {\n                                fixed (byte* m = metadata)\n                                    Buffer.MemoryCopy((void*)physicalAddress, m, entryLength, entryLength);\n                            }\n\n                            HybridLogRecoveryInfo recoveryInfo = new();\n                            using StreamReader s = new(new MemoryStream(metadata));\n                            recoveryInfo.Initialize(s);\n                            // Finish recovery if only specific versions are requested\n                            if (recoveryInfo.version == recoverTo) return;\n                        }\n\n                        break;\n                    default:\n                        throw new FasterException(\"Unexpected entry type\");\n\n                }\n            }\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        internal void MarkPage(long logicalAddress, long version)\n        {\n            var offset = (logicalAddress >> LogPageSizeBits) % BufferSize;\n            if (PageStatusIndicator[offset].Dirty < version)\n                PageStatusIndicator[offset].Dirty = version;\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        internal void MarkPageAtomic(long logicalAddress, long version)\n        {\n            var offset = (logicalAddress >> LogPageSizeBits) % BufferSize;\n            Utility.MonotonicUpdate(ref PageStatusIndicator[offset].Dirty, version, out _);","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Allocator/AllocatorBase.cs#L590-L626","documentation":"While replaying the allocator's (delta log / checkpoint) entries during recovery, FASTER switches on each entry's type; the default arm throws FasterException(\"Unexpected entry type\") because entry types are an internal enum and any value outside the known set means the log is corrupt or was written by an incompatible FASTER version.","triggerScenarios":"Recovering a hybrid log/checkpoint whose delta or checkpoint metadata contains an entry type byte not recognized by the current code — corrupted log files, truncation/torn writes, or log files produced by a different FASTER version with different entry-type encoding.","commonSituations":"Crash mid-write leaving partially written delta/checkpoint logs; manually copying checkpoint files between deployments with different FASTER versions; disk corruption of log devices.","solutions":["Verify the log/checkpoint files were produced by the same FASTER version you are recovering with; align versions if not.","If files are corrupt, discard and recreate the log/checkpoint directory (accepting data loss) or restore from a known-good checkpoint.","Enable/check device-level integrity (checksums, proper flush/fsync) to prevent torn writes, and rerun recovery from an earlier valid checkpoint."],"exampleFix":"// before\n// recovering logs written by FASTER 2.x with a 3.x binary\n// after\n// use the matching FASTER version to recover, or start fresh:\n// delete CheckpointDir/LogDir contents and re-initialize the store","handlingStrategy":"try-catch","validationCode":"// preflight: verify checkpoint dir exists and FASTER version matches the one that wrote the logs\nif (!Directory.Exists(checkpointDir) || !VersionMatch(writingVersion, currentVersion)) throw new InvalidOperationException(\"Checkpoint/log files incompatible with this FASTER version\");","typeGuard":null,"tryCatchPattern":"try { store.Recover(recoverTo); } catch (FasterException) { /* fall back to previous checkpoint or reinitialize the log */ }","preventionTips":["Pin the FASTER version used for writing and recovering logs.","Never hand-copy checkpoint files across deployments with different versions.","Enable proper flush/fsync and monitor storage health to avoid torn log writes."],"tags":["csharp","faster","recovery","corruption","version-compat"],"backgroundTag":"checksum-mismatch","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}