-
Notifications
You must be signed in to change notification settings - Fork 243
[DistributedLock.Redis] Bugfix: respect IDatabase key prefix #65
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
[DistributedLock.Redis] Bugfix: respect IDatabase key prefix #65
Conversation
madelson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skomis-mm thanks for filing this! I'd like to publish a patch release for this. Some steps for doing that:
- Can you please change the target branch of this PR to point to the new
release-2.0.1branch I created instead ofmaster? - See the comment I left about adding a couple of source code comments.
- I'll want to add test coverage around this. You are welcome to do so but I can also do it if you'd like; just let me know. The cases I want to add are:
(a) Add a new provider inTestingRedisDatabaseProviders.cswhich has a single database using a key prefix, then run theTestSetupTestto add new combinatorial tests based on this provider. This will give assurance that all operations across all the Redis classes are key prefix friendly.
(b) Add a test toRedisSynchronizationCoreTestCases.csthat does the following: (i) sets the test's databases to just default server 0 with a key prefix P and creates a lock named N. (ii) sets the test's database to just default server 0 and creates a lock named N, (iii) creates a lock named P + N. (iv) demonstrates that locks 1 and 2 do not interact, but 1 and 3 do interact.
|
|
||
| public Task<RedisResult> ExecuteAsync(IDatabaseAsync database, TArgument argument, bool fireAndForget = false) => | ||
| this._script.EvaluateAsync(database, this._parameters(argument), flags: RedLockHelper.GetCommandFlags(fireAndForget)); | ||
| database.ScriptEvaluateAsync(this._script, this._parameters(argument), flags: RedLockHelper.GetCommandFlags(fireAndForget)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this change is super subtle. Is the idea that all other IDatabase methods will add the key prefix too? We do use non-script evaluations in a few places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats right, .WithKeyPrefix(..) returns IDatabase decorator with the key prefix as context data.
|
will re-branch from 2.0.1 |
Fixes an issue with Redis keyspace isolation for locks using
WithKeyPrefixextension method onIDatabase: