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

Redis: use known commands correctly #36580

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Oct 19, 2023

Redis: use pre-existing command instances instead of using Command.create()

This is more idiomatic and prevents troubles with Redis cluster where
the Vert.x Redis client needs to know the key affected by the command
in order to route the command to the correct cluster node. That works
correctly with pre-existing Command instances and will not work
correctly with Command.create() until the Vert.x Redis client itself
is fixed.

Redis: normalize results of Command.create()

When the Command.create() method is used to create a Command instance
for a known command (not recommended, but also not forbidden), it returns
a generic instance that doesn't know anything about where the keys are in
the command. Such generic instance is unusable with Redis cluster, because
the target node will be selected randomly, not based on the key, and there's
high chance such command will result in the MOVED redirect.

With this commit, we normalize all results of Command.create() so that
a pre-existing static instance for known commands is used. This is key-aware
and works with Redis cluster.

This commit adapts a fix submitted to Vert.x Redis client. When we upgrade
to a fixed Vert.x Redis client, this commit should be reverted.

Fixes #28704

…eate()

This is more idiomatic and prevents troubles with Redis cluster where
the Vert.x Redis client needs to know the key affected by the command
in order to route the command to the correct cluster node. That works
correctly with pre-existing `Command` instances and will _not_ work
correctly with `Command.create()` until the Vert.x Redis client itself
is fixed.
@quarkus-bot

This comment has been minimized.

When the `Command.create()` method is used to create a `Command` instance
for a known command (not recommended, but also not forbidden), it returns
a generic instance that doesn't know anything about where the keys are in
the command. Such generic instance is unusable with Redis cluster, because
the target node will be selected randomly, not based on the key, and there's
high chance such command will result in the `MOVED` redirect.

With this commit, we normalize all results of `Command.create()` so that
a pre-existing static instance for known commands is used. This is key-aware
and works with Redis cluster.

This commit adapts a fix submitted to Vert.x Redis client. When we upgrade
to a fixed Vert.x Redis client, this commit should be reverted.
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 19, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Copy link
Member

@cescoffier cescoffier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@cescoffier cescoffier merged commit d35d52f into quarkusio:main Oct 19, 2023
30 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.6 - main milestone Oct 19, 2023
@Ladicek Ladicek deleted the redis-known-commands branch October 20, 2023 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken Redis client for cluster mode (MOVED Exception)
2 participants