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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -149,7 +149,7 @@ public async Task WriteStateAsync<T>(string grainType, GrainId grainId, IGrainSt
const string WriteScript =
"""
local etag = redis.call('HGET', KEYS[1], 'etag')
if (not etag and (ARGV[1] == nil or ARGV[1] == '')) or etag == ARGV[1] then
if ((not etag or etag == '') and (not ARGV[1] or ARGV[1] == '')) or etag == ARGV[1] then
redis.call('HMSET', KEYS[1], 'etag', ARGV[2], 'data', ARGV[3])
if ARGV[4] ~= '-1' then
redis.call('EXPIRE', KEYS[1], ARGV[4])
Expand Down Expand Up @@ -234,7 +234,7 @@ public async Task ClearStateAsync<T>(string grainType, GrainId grainId, IGrainSt
const string DeleteScript =
"""
local etag = redis.call('HGET', KEYS[1], 'etag')
if (not etag and not ARGV[1]) or etag == ARGV[1] then
if ((not etag or etag == '') and (not ARGV[1] or ARGV[1] == '')) or etag == ARGV[1] then
redis.call('DEL', KEYS[1])
return 0
else
Expand All @@ -249,7 +249,7 @@ public async Task ClearStateAsync<T>(string grainType, GrainId grainId, IGrainSt
const string ClearScript =
"""
local etag = redis.call('HGET', KEYS[1], 'etag')
if (not etag and not ARGV[1]) or etag == ARGV[1] then
if ((not etag or etag == '') and (not ARGV[1] or ARGV[1] == '')) or etag == ARGV[1] then
redis.call('HMSET', KEYS[1], 'etag', ARGV[2], 'data', '')
return 0
else
Expand Down Expand Up @@ -282,4 +282,4 @@ private async Task Close(CancellationToken cancellationToken)
_connection.Dispose();
}
}
}
}
Loading