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

fix: Support replicating Valkey and Redis 7.2 #3927

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Conversation

chakaz
Copy link
Collaborator

@chakaz chakaz commented Oct 15, 2024

Until now, we only tested Dragonfly against Redis 6.2. It appears that something has changed in the way Redis sends stable sync commands, and now they also forward MULTI and EXEC as part of their replication.

Since we do not allow all commands to run under MULTI/EXEC, specifically SELECT, a Dragonfly replica of such servers failed these commands and became inconsistent with the data on the master.

The proposed fix is to simply ignore (i.e. not execute) MULTI/EXEC coming from a Redis/Valkey master, and run the commands within those transactions individually, like we do for other transactions.

To test this we randomly choose a redis/valkey server based on 3 available installed binaries and test against them.

Until now, we only tested Dragonfly against Redis 6.2.  It appears that
something has changed in the way Redis sends stable sync commands, and
now they also forward `MULTI` and `EXEC` as part of their replication.

Since we do not allow all commands to run under `MULTI`/`EXEC`,
specifically `SELECT`, a Dragonfly replica of such servers failed these
commands and became inconsistent with the data on the master.

The proposed fix is to simply ignore (i.e. not execute) `MULTI`/`EXEC`
coming from a Redis/Valkey master, and run the commands within those
transactions individually, like we do for other transactions.

To test this we randomly choose a redis/valkey server based on 3
available installed binaries and test against them.
Comment on lines +640 to +643
// Valkey and Redis may send MULTI and EXEC as part of their replication commands.
// Dragonfly disallows some commands, such as SELECT, inside of MULTI/EXEC, so here we simply
// ignore MULTI/EXEC and execute their inner commands individually.
if (!absl::EqualsIgnoreCase(cmd, "MULTI") && !absl::EqualsIgnoreCase(cmd, "EXEC")) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only change here is the added if (with comments), and the usage of cmd in the VLOG below

@chakaz chakaz merged commit c868b27 into main Oct 15, 2024
12 checks passed
@chakaz chakaz deleted the chakaz/replicate-valkey branch October 15, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants