{"record":{"id":"c1240944593572ef","repo":"microsoft/FASTER","slug":"unable-to-find-session-sessionid-to-recover","errorCode":null,"errorMessage":"Unable to find session {sessionID} to recover","messagePattern":"Unable to find session (.+?) to recover","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"cs/src/core/ClientSession/FASTERClientSession.cs","lineNumber":273,"sourceCode":"        internal ClientSession<Key, Value, Input, Output, Context, Functions> ResumeSession<Input, Output, Context, Functions>(Functions functions, int sessionID, out CommitPoint commitPoint,\n                SessionVariableLengthStructSettings<Value, Input> sessionVariableLengthStructSettings = null, ReadCopyOptions readCopyOptions = default)\n            where Functions : IFunctions<Key, Value, Input, Output, Context>\n        {\n            return InternalResumeSession<Input, Output, Context, Functions, ClientSession<Key, Value, Input, Output, Context, Functions>>(functions, sessionID, out commitPoint,\n                        ctx => new ClientSession<Key, Value, Input, Output, Context, Functions>(this, ctx, functions, sessionVariableLengthStructSettings), readCopyOptions);\n        }\n\n        private TSession InternalResumeSession<Input, Output, Context, Functions, TSession>(Functions functions, int sessionID, out CommitPoint commitPoint,\n                                                                                            Func<FasterExecutionContext<Input, Output, Context>, TSession> sessionCreator, ReadCopyOptions readCopyOptions)\n             where TSession : IClientSession\n        {\n            if (functions == null)\n                throw new ArgumentNullException(nameof(functions));\n\n            string sessionName;\n            (sessionName, commitPoint) = InternalContinue<Input, Output, Context>(sessionID, out var ctx);\n            if (commitPoint.UntilSerialNo == -1)\n                throw new Exception($\"Unable to find session {sessionID} to recover\");\n            ctx.MergeReadCopyOptions(this.ReadCopyOptions, readCopyOptions);\n\n            var session = sessionCreator(ctx);\n\n            if (_activeSessions == null)\n                Interlocked.CompareExchange(ref _activeSessions, new Dictionary<int, SessionInfo>(), null);\n            lock (_activeSessions)\n                _activeSessions.Add(sessionID, new SessionInfo { sessionName = sessionName, session = session, isActive = true });\n            return session;\n        }\n\n        /// <summary>\n        /// Dispose session with FASTER\n        /// </summary>\n        /// <param name=\"sessionID\"></param>\n        /// <param name=\"sessionPhase\"></param>\n        /// <returns></returns>\n        internal void DisposeClientSession(int sessionID, Phase sessionPhase)","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/ClientSession/FASTERClientSession.cs#L255-L291","documentation":"After resuming a session by ID, FASTER checks the returned commit point: UntilSerialNo == -1 means InternalContinue found no durable checkpoint state for that session ID. The library then rejects the resume because there is nothing to recover.","triggerScenarios":"Calling ResumeSession/ResumeSessionById with a sessionID that was never checkpointed or whose recovery info was already consumed (UntilSerialNo == -1 returned from InternalContinue).","commonSituations":"Resuming by stale numeric session IDs from a previous process after the checkpoint set changed; double-resume of the same session ID; recovering a store whose checkpoint predates the session.","solutions":["Verify the session ID was captured from a checkpointed session and is present in the current recovery info.","Resume by session name instead of numeric ID to avoid stale-ID mismatches.","Fall back to NewSession if the ID no longer exists in recovery info.","Avoid resuming the same session ID more than once."],"exampleFix":"// before\nvar session = fht.ResumeSessionById<Functions>(functions, staleId, out var cp);\n// after\ntry\n{\n    var session = fht.ResumeSessionById<Functions>(functions, staleId, out var cp);\n}\ncatch (FasterException)\n{\n    var session = fht.NewSession<Functions>(functions);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    session = fht.ResumeSessionById<Functions>(functions, sessionId, out var cp);\n}\ncatch (FasterException ex) when (ex.Message.Contains(\"Unable to find session\"))\n{\n    session = fht.NewSession<Functions>(functions); // fall back to fresh session\n}","preventionTips":["Prefer name-based resume over raw numeric session IDs.","Persist session IDs together with the checkpoint they belong to.","Never reuse a session ID across recoveries."],"tags":["csharp","session-management","recovery","faster"],"backgroundTag":"record-not-found","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"}