{"record":{"id":"39b70e8b3a21b33f","repo":"microsoft/FASTER","slug":"session-named-sessionname-already-exists-in-recovery-info","errorCode":null,"errorMessage":"Session named {sessionName} already exists in recovery info, use RecoverSession to resume it","messagePattern":"Session named (.+?) already exists in recovery info, use RecoverSession to resume it","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/ClientSession/FASTERClientSession.cs","lineNumber":170,"sourceCode":"        /// <returns>Session instance</returns>\n        internal ClientSession<Key, Value, Input, Output, Context, Functions> NewSession<Input, Output, Context, Functions>(Functions functions, string sessionName = null,\n                SessionVariableLengthStructSettings<Value, Input> sessionVariableLengthStructSettings = null, ReadCopyOptions readCopyOptions = default)\n            where Functions : IFunctions<Key, Value, Input, Output, Context>\n            => InternalNewSession<Input, Output, Context, Functions, ClientSession<Key, Value, Input, Output, Context, Functions>>(functions, sessionName,\n                            ctx => new ClientSession<Key, Value, Input, Output, Context, Functions>(this, ctx, functions, sessionVariableLengthStructSettings), readCopyOptions);\n\n        private TSession InternalNewSession<Input, Output, Context, Functions, TSession>(Functions functions, string sessionName,\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            if (sessionName == \"\")\n                throw new FasterException(\"Cannot use empty string as session name\");\n\n            if (sessionName != null && _recoveredSessionNameMap != null && _recoveredSessionNameMap.ContainsKey(sessionName))\n                throw new FasterException($\"Session named {sessionName} already exists in recovery info, use RecoverSession to resume it\");\n\n            int sessionID = Interlocked.Increment(ref maxSessionID);\n            var ctx = new FasterExecutionContext<Input, Output, Context>();\n            InitContext(ctx, sessionID, sessionName);\n            ctx.MergeReadCopyOptions(this.ReadCopyOptions, readCopyOptions);\n            var prevCtx = new FasterExecutionContext<Input, Output, Context>();\n            InitContext(prevCtx, sessionID, sessionName);\n            prevCtx.version--;\n            prevCtx.ReadCopyOptions = ctx.ReadCopyOptions;\n\n            ctx.prevCtx = prevCtx;\n\n            if (_activeSessions == null)\n                Interlocked.CompareExchange(ref _activeSessions, new Dictionary<int, SessionInfo>(), null);\n\n            var session = sessionCreator(ctx);\n            lock (_activeSessions)\n                _activeSessions.Add(sessionID, new SessionInfo { sessionName = sessionName, session = session, isActive = true });","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/ClientSession/FASTERClientSession.cs#L152-L188","documentation":"FASTER tracks sessions that exist in checkpoint/recovery info by name. When NewSession is called with a sessionName that already appears in _recoveredSessionNameMap, the library refuses to create a duplicate because that name must be resumed with RecoverSession/ResumeSession instead of created fresh.","triggerScenarios":"Calling fht.NewSession<...>(functions, sessionName: \"mySession\") where \"mySession\" was previously checkpointed (exists in _recoveredSessionNameMap), instead of calling RecoverSession.","commonSituations":"Reopening a FASTER instance from checkpoints after a restart and blindly creating sessions with the same names used before the checkpoint; session-name collisions after failover recovery.","solutions":["Call fht.RecoverSession(sessionName) (or ResumeSession) instead of NewSession to resume the recovered session.","Use a unique new sessionName for NewSession calls.","Pass null as sessionName to let FASTER auto-generate an unnamed session if recovery-by-name is not needed."],"exampleFix":"// before\nvar session = fht.NewSession<Functions>(functions, sessionName: \"worker1\");\n// after\nvar session = fht.RecoverSession<Functions>(functions, sessionName: \"worker1\", out CommitPoint cp);","handlingStrategy":"validation","validationCode":"fht.Recover(); // ensure recovery info is loaded\nif (recoveredSessionNames.Contains(sessionName))\n    session = fht.RecoverSession<Functions>(functions, sessionName, out var cp);\nelse\n    session = fht.NewSession<Functions>(functions, sessionName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a registry of session names that were checkpointed.","Always call Recover() before creating named sessions on a reopened store.","Use deterministic, unique session names per process generation."],"tags":["csharp","session-management","recovery","faster"],"backgroundTag":"file-already-exists","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"}