{"record":{"id":"94dea35010d6e951","repo":"microsoft/FASTER","slug":"invoke-iterate-on-a-client-session-clientsession-or-use","errorCode":null,"errorMessage":"Invoke Iterate() on a client session (ClientSession), or use store.Iterate overload with Functions provided as parameter","messagePattern":"Invoke Iterate\\(\\) on a client session \\(ClientSession\\), or use store\\.Iterate overload with Functions provided as parameter","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Index/FASTER/FASTERIterator.cs","lineNumber":60,"sourceCode":"                return false;\n\n            long numRecords = 1;\n            bool stop = false;\n            for ( ; !stop && iter.PushNext(ref scanFunctions, numRecords, out stop); ++numRecords)\n                ;\n\n            scanFunctions.OnStop(!stop, numRecords);\n            return !stop;\n        }\n\n        /// <summary>\n        /// Iterator for all (distinct) live key-values stored in FASTER\n        /// </summary>\n        /// <param name=\"untilAddress\">Report records until this address (tail by default)</param>\n        /// <returns>FASTER iterator</returns>\n        [Obsolete(\"Invoke Iterate() on a client session (ClientSession), or use store.Iterate overload with Functions provided as parameter\")]\n        public IFasterScanIterator<Key, Value> Iterate(long untilAddress = -1) \n            => throw new FasterException(\"Invoke Iterate() on a client session (ClientSession), or use store.Iterate overload with Functions provided as parameter\");\n\n        /// <summary>\n        /// Iterator for all (distinct) live key-values stored in FASTER\n        /// </summary>\n        /// <param name=\"compactionFunctions\">User provided compaction functions (see <see cref=\"ICompactionFunctions{Key, Value}\"/>).</param>\n        /// <param name=\"untilAddress\">Report records until this address (tail by default)</param>\n        /// <returns>FASTER iterator</returns>\n        [Obsolete(\"Invoke Iterate() on a client session (ClientSession), or use store.Iterate overload with Functions provided as parameter\")]\n        public IFasterScanIterator<Key, Value> Iterate<CompactionFunctions>(CompactionFunctions compactionFunctions, long untilAddress = -1)\n            where CompactionFunctions : ICompactionFunctions<Key, Value> \n            => throw new FasterException(\"Invoke Iterate() on a client session (ClientSession), or use store.Iterate overload with Functions provided as parameter\");\n    }\n\n    internal sealed class FasterKVIterator<Key, Value, Input, Output, Context, Functions> : IFasterScanIterator<Key, Value>\n        where Functions : IFunctions<Key, Value, Input, Output, Context>\n    {\n        private readonly FasterKV<Key, Value> fht;\n        private readonly FasterKV<Key, Value> tempKv;","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Index/FASTER/FASTERIterator.cs#L42-L78","documentation":"This parameterless/store-level Iterate overload is intentionally dead: it is marked [Obsolete] and its body unconditionally throws FasterException. FASTER removed direct store iteration; iteration must go through a client session so user IFunctions (checksums, concurrent reads) are supplied. Any call reaches this throw immediately.","triggerScenarios":"Calling store.Iterate() (or store.Iterate(untilAddress)) on a FasterKV instance directly, e.g. code written against pre-session FASTER APIs or samples copied from old blog posts.","commonSituations":"Upgrading FASTER from an older version where store.Iterate worked; writing a one-off scan/dump tool without creating a ClientSession.","solutions":["Create a client session and call its Iterate: fht.For Functions... .NewSession Functions and session.Iterate(...).","Use the store.Iterate overload that takes IFunctions/ICompactionFunctions parameters.","Remove references to the obsolete overload (compiler CS0618 warning points at it)."],"exampleFix":"// before\nusing var iter = store.Iterate();\n// after\nusing var session = store.For(new Functions()).NewSession<Functions>();\nusing var iter = session.Iterate();","handlingStrategy":"type-guard","validationCode":"// Do not call store.Iterate() at all; resolve the session-based API instead.\nusing var session = store.For(new Functions()).NewSession<Functions>();\nusing var iter = session.Iterate();","typeGuard":"static bool IsObsoleteStoreIterate(System.Reflection.MethodInfo m) =>\n    m.Name == nameof(FasterKV<int,int>.Iterate) && m.IsDefined(typeof(ObsoleteAttribute), false);","tryCatchPattern":"catch (FasterException ex) when (ex.Message.Contains(\"Invoke Iterate() on a client session\"))\n{ throw new NotSupportedException(\"Use session.Iterate() instead of store.Iterate()\", ex); }","preventionTips":["Treat CS0618 obsolete warnings as build errors so obsolete Iterate calls fail compilation.","Wrap all FASTER scanning behind one helper that uses ClientSession iteration.","Check the FASTER migration notes when upgrading versions before using iteration APIs."],"tags":["faster","deprecated-api","iteration","csharp"],"backgroundTag":"deprecated-api-usage","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"}