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

Command.XREADGROUP error MOVED #440

Open
fmeneghetti opened this issue Mar 26, 2024 · 9 comments
Open

Command.XREADGROUP error MOVED #440

fmeneghetti opened this issue Mar 26, 2024 · 9 comments
Labels

Comments

@fmeneghetti
Copy link

I am experiencing some issues in Redis Cluster mode, particularly with the MOVED error.
It is still unclear to me how to transparently handle this when the cluster is unbalanced.

I think there is a problem with the "xreadgroup" command, though, because unlike the "xread" command, which is a read command, "xreadgroup" is a write command.

In RedisReplicas.SHARE or RedisReplicas.ALWAYS mode I run into the MOVED error.

I suppose it is to treat the command as "master only":

addMasterOnlyCommand(XREADGROUP);

vertx-redis-client -> 4.5.6

@Ladicek
Copy link
Contributor

Ladicek commented Mar 26, 2024

All commands that are not read-only are routed to master nodes already, so that is not an issue.

I noticed a while ago that we transparently handle ASKED redirections, but propagate MOVED redirections as errors. I don't know why we do that, the Redis cluster design assumes that clients handle MOVED redirections as well. That is an issue we have, I believe.

@fmeneghetti
Copy link
Author

I think there is a problem with the "xreadGroup" command because it is recognized as "readOnly" and therefore is also sent to the replication nodes.

@fmeneghetti
Copy link
Author

Command XREADGROUP = new CommandImpl("xreadgroup", -7, false, false, false, new KeyLocator(true, new BeginSearchKeyword("STREAMS", 4), new FindKeysRange(-1, 1, 2)));

The first param is Boolean readOnly

@Ladicek
Copy link
Contributor

Ladicek commented Mar 26, 2024

You might want to debug CommandImpl.isReadOnly(), which determines if the command is actually treated as read-only, based on argument values first.

@fmeneghetti
Copy link
Author

I did it:

15:58:46.761 [vert.x-eventloop-thread-2] INFO i.m.s.v.tst.pri.TstDeployerVerticle - XREADGROUP GROUP mgg.signal.workers mgg.signal.worker:1 COUNT 1 BLOCK 1000 STREAMS stream:message >
15:58:46.761 [vert.x-eventloop-thread-2] INFO i.m.s.v.tst.pri.TstDeployerVerticle - command=xreadgroup
15:58:46.761 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]keySlot=1163
15:58:46.761 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]readOnly=true
15:58:46.761 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]endpoints=[redis://172.26.0.101:7001, redis://172.26.0.105:7005]
15:58:46.761 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]endpoint=redis://172.26.0.105:7005
15:58:46.761 [vert.x-eventloop-thread-2] ERROR i.v.r.c.impl.RedisClusterConnection - [redis]MOVED 1163 172.26.0.101:7001

@fmeneghetti
Copy link
Author

After changing the "ro" parameter of the KeyLocator class, I saw that things are working fine:

Command XREADGROUP = new CommandImpl("xreadgroup", -7, false, false, false, new KeyLocator(false, new BeginSearchKeyword("STREAMS", 4), new FindKeysRange(-1, 1, 2)));


16:04:49.681 [vert.x-eventloop-thread-2] INFO i.m.s.v.tst.pri.TstDeployerVerticle - XREADGROUP GROUP mgg.signal.workers mgg.signal.worker:1 COUNT 1 BLOCK 1000 STREAMS stream:message >
16:04:49.681 [vert.x-eventloop-thread-2] INFO i.m.s.v.tst.pri.TstDeployerVerticle - command=xreadgroup
16:04:49.681 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]keySlot=1163
16:04:49.681 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]readOnly=false
16:04:49.681 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]endpoints=[redis://172.26.0.101:7001, redis://172.26.0.105:7005]
16:04:49.681 [vert.x-eventloop-thread-2] INFO i.v.r.c.impl.RedisClusterConnection - [redis]endpoint=redis://172.26.0.101:7001

now in the log is printed correctly: "readOnly=false"

@Ladicek
Copy link
Contributor

Ladicek commented Mar 26, 2024

Funny. The command descriptors are automatically generated from Redis COMMAND output (https://redis.io/commands/command/), so should be correct. Maybe we have a bug in the isReadOnly logic, I'd have to take a proper look, I didn't have to dig into that deeply yet.

@fmeneghetti
Copy link
Author

Hi @Ladicek, do you have news? Thanks.

@Ladicek
Copy link
Contributor

Ladicek commented May 28, 2024

I don't have any news, no.

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

No branches or pull requests

2 participants