{"record":{"id":"0a595772ddeb75e1","repo":"microsoft/garnet","slug":"consistent-read-context-does-not-reset-resetmodifi","errorCode":null,"errorMessage":"Consistent read context does not reset ResetModified!","messagePattern":"Consistent read context does not reset ResetModified!","errorType":"exception","errorClass":"TsavoriteException","httpStatus":null,"severity":"error","filePath":"libs/storage/Tsavorite/cs/src/core/ClientSession/ConsistentReadContext.cs","lineNumber":283,"sourceCode":"        /// <inheritdoc/>\n        public Status RMW(TKey key, ref TInput input, TContext userContext = default)\n            => throw new TsavoriteException(\"Consistent read context does not allow writes!\");\n\n        /// <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":265,"sourceCodeEnd":290,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/storage/Tsavorite/cs/src/core/ClientSession/ConsistentReadContext.cs#L265-L290","documentation":"ResetModified marks a key as no longer modified within a transactional context. ConsistentReadContext does not support this because it is a read-only snapshot view — it has no transactional write state to reset. The method is implemented as an unconditional throw to satisfy the ITsavoriteContext interface contract while making the limitation explicit. Note the message text 'does not reset ResetModified' is slightly awkward but intentional.","triggerScenarios":"Calling ResetModified(TKey key) on the ConsistentReadContext struct. This can happen when transactional code that calls ResetModified is refactored to use the consistent-read context, or when an ITsavoriteContext-typed variable that happens to hold a ConsistentReadContext is used.","commonSituations":"Transaction management code that tracks modified keys and calls ResetModified after processing; mixing transactional and consistent-read patterns in the same session lifecycle.","solutions":["Call ResetModified on the TransactionalContext (session.TransactionalContext) or BasicContext, not on ConsistentReadContext.","If using TransactionalConsistentReadContext for reads inside a transaction, note that ResetModified is also rejected there — use the non-consistent TransactionalContext for transactional write state management."],"exampleFix":"// before (throws)\nsession.ConsistentReadContext.ResetModified(key);\n\n// after\nsession.TransactionalContext.ResetModified(key);","handlingStrategy":"validation","validationCode":"// Call ResetModified on a context that supports transactional write state\n// ConsistentReadContext does not support ResetModified\nsession.TransactionalContext.ResetModified(key);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Track which context types support transactional state operations (TransactionalContext, BasicContext) vs read-only (ConsistentReadContext, TransactionalConsistentReadContext).","Document at the class level which context each method should be called on."],"tags":["tsavorite","consistent-read","read-only-context","reset-modified","transactional-state","write-rejected","csharp"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}