{"record":{"id":"37276dbf773d59f2","repo":"microsoft/FASTER","slug":"unexpected-entry-type-devicelogcommitcheckpointmanager","errorCode":null,"errorMessage":"Unexpected entry type","messagePattern":"Unexpected entry type","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Index/CheckpointManagement/DeviceLogCommitCheckpointManager.cs","lineNumber":314,"sourceCode":"                            // consider only metadata records\n                            continue;\n                        case DeltaLogEntryType.CHECKPOINT_METADATA:\n                            metadata = new byte[entryLength];\n                            unsafe\n                            {\n                                fixed (byte* m = metadata)\n                                    Buffer.MemoryCopy((void*)physicalAddress, m, entryLength, entryLength);\n                            }\n                            HybridLogRecoveryInfo recoveryInfo = new();\n                            using (StreamReader s = new(new MemoryStream(metadata)))\n                            {\n                                recoveryInfo.Initialize(s);\n                                // Finish recovery if only specific versions are requested\n                                if (recoveryInfo.version == recoverTo || recoveryInfo.version < recoverTo && recoveryInfo.nextVersion > recoverTo) goto LoopEnd;\n                            }\n                            continue;\n                        default:\n                            throw new FasterException(\"Unexpected entry type\");\n                    }\n                LoopEnd:\n                    break;\n                }\n                if (metadata != null) return metadata;\n\n            }\n\n            var device = deviceFactory.Get(checkpointNamingScheme.LogCheckpointMetadata(logToken));\n\n            ReadInto(device, 0, out byte[] writePad, sizeof(int));\n            int size = BitConverter.ToInt32(writePad, 0);\n\n            byte[] body;\n            if (writePad.Length >= size + sizeof(int))\n                body = writePad;\n            else\n                ReadInto(device, 0, out body, size + sizeof(int));","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Index/CheckpointManagement/DeviceLogCommitCheckpointManager.cs#L296-L332","documentation":"While scanning the delta log in GetLogCheckpointMetadata, each entry carries an entry type (e.g. CHECKPOINT_METADATA, another known type, or unknown). The switch's default arm throws FasterException(\"Unexpected entry type\") when an entry with an unrecognized DeltaLogEntryType is encountered. This indicates a corrupt or foreign delta log record that the current code does not know how to interpret.","triggerScenarios":"Calling GetLogCheckpointMetadata (directly or via Recover with scanDelta=true) when the delta log contains an entry whose type is not one of the handled DeltaLogEntryType values, hitting the switch default.","commonSituations":"Delta log corrupted by a crash mid-write; delta log written by a different (newer/older) library version with extra entry types; reading a device file that is not actually this format.","solutions":["Restore the checkpoint files from a known-good backup; the delta log is corrupt or unreadable.","Recover from the base (full) checkpoint metadata instead of scanning the delta log (scanDelta=false or recoverTo the last full version).","Ensure the reading library version matches the version that wrote the checkpoint; version skew can introduce unknown entry types.","Do not hand-edit or share delta log files across incompatible processes."],"exampleFix":"// before\nvar meta = checkpointManager.GetLogCheckpointMetadata(token, deltaLog, scanDelta: true, recoverTo: version);\n\n// after\nvar meta = checkpointManager.GetLogCheckpointMetadata(token, deltaLog, scanDelta: false, recoverTo: -1); // read full metadata, skip risky delta scan\nif (meta == null) throw new InvalidOperationException($\"No metadata for checkpoint {token}\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { meta = manager.GetLogCheckpointMetadata(token, deltaLog, scanDelta: true, recoverTo); } catch (FasterException ex) when (ex.Message == \"Unexpected entry type\") { meta = manager.GetLogCheckpointMetadata(token, deltaLog, scanDelta: false, recoverTo: -1); }","preventionTips":["Use matching library versions between writer and reader of checkpoints.","Never hand-edit or truncate delta log files.","Restore from full-checkpoint metadata when delta logs look suspect."],"tags":["checkpoint","delta-log","corruption","fasterlog"],"backgroundTag":"invalid-enum-value","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}