Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exceptions accessing nonexistent etags in RedisGrainStorage #9147

Merged

Conversation

hendrikdevloed
Copy link
Contributor

@hendrikdevloed hendrikdevloed commented Sep 25, 2024

This is a Redis-only solution for the issue which was reported to affect both ADO.NET and Redis. #3516 (comment)

The workaround so far was to avoid clearing nonexistent state, but that put the burden on the user of the persistence layer. In case of a third-party library using the persistence layer, this would require patching it.

Cause

The Redis built-in LUA engine has a peculiarity that it properly returns "nil" for nonexistent results when accessed e.g. through the EVAL "script" command, but within the script it translate these "nil" to "false", which makes "==nil" checks behave in a non-intuitive manner.
redis/redis#2721

Solution

As recommended by @ReubenBond, the C# code that builds up the argument list and calls the LUA script was left untouched. The empty string as a proxy for a null was kept. Next to that, the LUA nil behaviour was taken into account to check something for its absence: (not something or something='') instead of "==nil" which doesn't work as expected intuitively.

Next to this solution, some equivalent fix for ADO.NET will be required to address further #3516

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond force-pushed the redis-clearstateasync-null-etag branch from 8176ebb to b769aee Compare October 1, 2024 20:40
@ReubenBond ReubenBond merged commit ac1a3b5 into dotnet:main Oct 1, 2024
22 checks passed
@ReubenBond
Copy link
Member

Thank you, @hendrikdevloed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants