{"record":{"id":"4db51eb042ce4fe0","repo":"microsoft/garnet","slug":"consistent-read-context-does-not-reset-refresh","errorCode":null,"errorMessage":"Consistent read context does not reset Refresh!","messagePattern":"Consistent read context does not reset Refresh!","errorType":"exception","errorClass":"TsavoriteException","httpStatus":null,"severity":"error","filePath":"libs/storage/Tsavorite/cs/src/core/ClientSession/ConsistentReadContext.cs","lineNumber":287,"sourceCode":"        /// <inheritdoc/>\n        public Status RMW(TKey key, ref TInput input, ref RMWOptions rmwOptions, TContext userContext = default)\n            => throw new TsavoriteException(\"Consistent read context does not allow writes!\");\n\n        /// <inheritdoc/>\n        public Status Delete(TKey key, TContext userContext = default)\n            => throw new TsavoriteException(\"Consistent read context does not allow writes!\");\n\n        /// <inheritdoc/>\n        public Status Delete(TKey key, ref DeleteOptions deleteOptions, TContext userContext = default)\n            => throw new TsavoriteException(\"Consistent read context does not allow writes!\");\n\n        /// <inheritdoc/>\n        public void ResetModified(TKey key)\n            => throw new TsavoriteException(\"Consistent read context does not reset ResetModified!\");\n\n        /// <inheritdoc/>\n        public void Refresh()\n            => throw new TsavoriteException(\"Consistent read context does not reset Refresh!\");\n        #endregion\n    }\n}","sourceCodeStart":269,"sourceCodeEnd":290,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/storage/Tsavorite/cs/src/core/ClientSession/ConsistentReadContext.cs#L269-L290","documentation":"Refresh advances the session's read version to see commits made after the session's current version. ConsistentReadContext rejects this because it is designed for stable snapshot reads — refreshing would change the snapshot and violate the consistent-read contract. The throw is unconditional.","triggerScenarios":"Calling Refresh() on the ConsistentReadContext struct. This occurs when a developer wants to update the consistent-read snapshot to see newer committed data but calls Refresh on the read-only context rather than on the session or BasicContext.","commonSituations":"Long-lived read sessions that periodically need to see new commits; misunderstanding that ConsistentReadContext is a fixed-snapshot view rather than a live cursor.","solutions":["Call Refresh() on the ClientSession or BasicContext to advance the session version, then resume reads on ConsistentReadContext.","If you need a moving snapshot, consider not using ConsistentReadContext and instead using BasicContext.Read with appropriate read options.","Dispose and recreate the session (or obtain a fresh ConsistentReadContext) if a clean snapshot reset is needed."],"exampleFix":"// before (throws)\nsession.ConsistentReadContext.Refresh();\n\n// after\nsession.BasicContext.Refresh();","handlingStrategy":"validation","validationCode":"// Refresh the session version through a context that supports it\n// ConsistentReadContext does not support Refresh\nsession.BasicContext.Refresh();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Understand that ConsistentReadContext is a fixed snapshot — it cannot be refreshed in place.","If you need to see newer commits, call Refresh on BasicContext or the session, not on the read-only context."],"tags":["tsavorite","consistent-read","read-only-context","refresh","session-version","snapshot","csharp"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}