{"record":{"id":"7153c8b0f5cfa1a6","repo":"microsoft/garnet","slug":"retrievecheckpointfile-unexpected-state-retstatet","errorCode":null,"errorMessage":"RetrieveCheckpointFile: unexpected state{retStateType}","messagePattern":"RetrieveCheckpointFile: unexpected state(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/cluster/Server/Replication/GarnetClusterCheckpointManager.cs","lineNumber":65,"sourceCode":"            => checkpointVersionShiftStart?.Invoke(isMainStore, oldVersion, newVersion, isStreaming);\n\n        public override void CheckpointVersionShiftEnd(long oldVersion, long newVersion, bool isStreaming)\n            => checkpointVersionShiftEnd?.Invoke(isMainStore, oldVersion, newVersion, isStreaming);\n\n        public void DeleteLogCheckpoint(Guid logToken)\n            => deviceFactory.Delete(checkpointNamingScheme.LogCheckpointBase(logToken));\n\n        public void DeleteIndexCheckpoint(Guid indexToken)\n            => deviceFactory.Delete(checkpointNamingScheme.IndexCheckpointBase(indexToken));\n\n        public IDevice GetDevice(CheckpointFileType retStateType, Guid fileToken)\n        {\n            var device = retStateType switch\n            {\n                CheckpointFileType.STORE_INDEX => GetIndexDevice(fileToken),\n                CheckpointFileType.STORE_SNAPSHOT => GetSnapshotLogDevice(fileToken),\n                CheckpointFileType.STORE_SNAPSHOT_OBJ => GetSnapshotObjectLogDevice(fileToken),\n                _ => throw new Exception($\"RetrieveCheckpointFile: unexpected state{retStateType}\")\n            };\n            return device;\n        }\n\n        #region ICheckpointManager\n\n        private HybridLogRecoveryInfo ConvertMetadata(byte[] checkpointMetadata)\n        {\n            HybridLogRecoveryInfo recoveryInfo = new();\n\n            // Try to parse new format where cookie is embedded inside the HybridLogRecoveryInfo\n            try\n            {\n                using var s = new StreamReader(new MemoryStream(checkpointMetadata));\n                recoveryInfo.Initialize(s);\n            }\n            catch (Exception ex)\n            {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/cluster/Server/Replication/GarnetClusterCheckpointManager.cs#L47-L83","documentation":"Thrown by GarnetClusterCheckpointManager.GetDevice when retStateType is not STORE_INDEX, STORE_SNAPSHOT, or STORE_SNAPSHOT_OBJ. The device factory only knows how to open devices for those three checkpoint file kinds; any other CheckpointFileType is a programming error in the recovery/checkpoint-load path.","triggerScenarios":"Requesting a device for a STORE_HLOG, STORE_HLOG_OBJ, STORE_RANGEINDEX_*, NONE, or out-of-range file type through this GetDevice method.","commonSituations":"A recovery path that requests the hlog device via GetDevice instead of the dedicated hlog device accessor; new checkpoint file types added without a GetDevice arm.","solutions":["Use GetDevice only for STORE_INDEX, STORE_SNAPSHOT, STORE_SNAPSHOT_OBJ.","For hybrid-log devices, use the dedicated hlog device accessor rather than this dispatch method.","Extend the switch when a new file type needs device access."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Only request devices for supported file types\nif (fileType is not (CheckpointFileType.STORE_INDEX or CheckpointFileType.STORE_SNAPSHOT or CheckpointFileType.STORE_SNAPSHOT_OBJ))\n    throw new ArgumentOutOfRangeException(nameof(fileType), fileType, \"GetDevice supports index/snapshot file types only\");\nreturn manager.GetDevice(fileType, token);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use GetDevice only for index/snapshot file types; use dedicated accessors for hlog devices.","Extend the switch when new file types require device access.","Document which file types each device accessor supports."],"tags":["cluster","replication","checkpoint","io","enum-switch","garnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}