redis / lettuce

Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
https://lettuce.io
MIT License
5.3k stars 947 forks source link

Why does lecttuce send lua script load command to all nodes (including replicas) in redis cluster? #2853

Closed hungphan227 closed 1 month ago

hungphan227 commented 1 month ago

I tried scriptLoad method of Lecttuce with Redis cluster (3 master, 2 replicas, 1 replica down)

Expected: scriptLoad method run successfully

Actual: An error occurred that informed lecttuce could not connect to one node in the cluster

It seems that Lecttuce has to send the command to all the nodes in the redis cluster. If a replica node is down, the request would fail.

As I understand, Redis has a mechanism to replicate everything from master to replica. So why does lecttuce have to send lua script load command to all nodes (including replicas) in redis cluster?

tishun commented 1 month ago

Hey @hungphan227 ,

this was already discussed in #720.

Could you go over the discussion there and let me know if you still have questions / concerns on the topic?

hungphan227 commented 1 month ago

I have read https://github.com/redis/lettuce/issues/720 before but it did not explicitly explain why lecttuce has to send lua script load command to replicas. Isn't replicating lua script to replicas (from master) done by redis cluster itself?

tishun commented 1 month ago

They are not replicated, as far as I know.

From the official documentation :

Although the server executes them, Eval scripts are regarded as a part of the client-side application, which is why they're not named, versioned, or persisted. So all scripts may need to be reloaded by the application at any time if missing (after a server restart, fail-over to a replica, etc.). As of version 7.0, Redis Functions offer an alternative approach to programmability which allow the server itself to be extended with additional programmed logic.

hungphan227 commented 1 month ago

Oh tks a lot :))