microsoft/garnet · error · TsavoriteException
Consistent read context does not reset Refresh!
Error message
Consistent read context does not reset Refresh!
What it means
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.
Source
Thrown at libs/storage/Tsavorite/cs/src/core/ClientSession/ConsistentReadContext.cs:287
/// <inheritdoc/>
public Status RMW(TKey key, ref TInput input, ref RMWOptions rmwOptions, TContext userContext = default)
=> throw new TsavoriteException("Consistent read context does not allow writes!");
/// <inheritdoc/>
public Status Delete(TKey key, TContext userContext = default)
=> throw new TsavoriteException("Consistent read context does not allow writes!");
/// <inheritdoc/>
public Status Delete(TKey key, ref DeleteOptions deleteOptions, TContext userContext = default)
=> throw new TsavoriteException("Consistent read context does not allow writes!");
/// <inheritdoc/>
public void ResetModified(TKey key)
=> throw new TsavoriteException("Consistent read context does not reset ResetModified!");
/// <inheritdoc/>
public void Refresh()
=> throw new TsavoriteException("Consistent read context does not reset Refresh!");
#endregion
}
}View on GitHub (pinned to 951b0fc683)
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.
Example fix
// before (throws) session.ConsistentReadContext.Refresh(); // after session.BasicContext.Refresh();
Defensive patterns
Strategy: validation
Validate before calling
// Refresh the session version through a context that supports it // ConsistentReadContext does not support Refresh session.BasicContext.Refresh();
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Long-lived read sessions that periodically need to see new commits; misunderstanding that ConsistentReadContext is a fixed-snapshot view rather than a live cursor.
Related errors
- Transactional consistent read context does not Refresh!
- Consistent read context does not allow writes!
- Consistent read context does not reset ResetModified!
- Transactional consistent read context does not allow reads f
- Consistent read context does not allow writes!
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/4db51eb042ce4fe0.
Report an issue: GitHub.