Pass at least one key to script executions#49
Pass at least one key to script executions#49nyergler wants to merge 9 commits intotaylorchu:masterfrom
Conversation
|
We run sentinel but getting this to work sounds good to me. I will try to add a circle ci redis "cluster" environment for this here: Line 35 in 78a4fef the previous idea is to use this "hash" in either name space or queue name:
|
|
We were previously specifying the namespace using For what it's worth, we deployed this initially just specifying the hash tag as the namespace (in |
|
I need more info to produce this locally.
|
|
Hey @taylorchu, makes sense; I'll come up with a crisp set of repro steps and update here. |
This allows Redis to route our execution to the correct node when running in a Redis Cluster.
Quick fix. We use the heartbeat middlewear which allows long-running jobs to work. However, the context is also ending up canceled which is causing other issues.
|
@jpalawaga @nyergler could you check if 016e03b fixes it? |
|
backstory: it turns out go-redis 9.0.3 fixes a bug where it might take the first non key (normal args) as routing key, so this problem is not surfaced. after upgrading to 9.0.5, I finally can reproduce this problem and fix it. |
This allows Redis to route our execution to the correct node when running against a Redis Cluster.
I encountered this issue with an on premises deployment of our application, in which our customer is using Redis Cluster. They were seeing errors with cross-slot key access in a Lua script. This surprised me, since I knew that
workprovides a mechanism for namespacing keys to avoid this very problem.And then I read the following in the
EVALdocs:When I noticed that work doesn't pass any keys to the script evaluation, I surmised that this allowed Redis to route the script to any node in the cluster.
This PR is the minimal update to fix this issue, passing a single namespaced key to the script evaluation.
A more thorough, albeit slightly more invasive, fix would be to perform all key composition outside the script. That would also have the nice advantage of not requiring the Lua & Go key creation to be kept in sync.
If you're open to that, I'll happily update my fork and this PR.