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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/server/replica.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,18 +635,24 @@ error_code Replica::ConsumeRedisStream() {
}

if (!LastResponseArgs().empty()) {
VLOG(2) << "Got command " << absl::CHexEscape(ToSV(LastResponseArgs()[0].GetBuf()))
<< "\n consumed: " << response->total_read;

if (LastResponseArgs()[0].GetBuf()[0] == '\r') {
for (const auto& arg : LastResponseArgs()) {
LOG(INFO) << absl::CHexEscape(ToSV(arg.GetBuf()));
string_view cmd = absl::CHexEscape(ToSV(LastResponseArgs()[0].GetBuf()));

// 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")) {
Comment on lines +640 to +643
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

VLOG(2) << "Got command " << cmd << "\n consumed: " << response->total_read;

if (LastResponseArgs()[0].GetBuf()[0] == '\r') {
for (const auto& arg : LastResponseArgs()) {
LOG(INFO) << absl::CHexEscape(ToSV(arg.GetBuf()));
}
}
}

facade::RespExpr::VecToArgList(LastResponseArgs(), &args_vector);
CmdArgList arg_list{args_vector.data(), args_vector.size()};
service_.DispatchCommand(arg_list, &conn_context);
facade::RespExpr::VecToArgList(LastResponseArgs(), &args_vector);
CmdArgList arg_list{args_vector.data(), args_vector.size()};
service_.DispatchCommand(arg_list, &conn_context);
}
}

io_buf.ConsumeInput(response->left_in_buffer);
Expand Down
4 changes: 3 additions & 1 deletion tests/dragonfly/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import threading
import time
import subprocess
import random
import aiohttp
import logging
from dataclasses import dataclass
Expand Down Expand Up @@ -455,8 +456,9 @@ def __init__(self, port):
self.proc = None

def start(self, **kwargs):
servers = ["redis-server-6.2.11", "redis-server-7.2.2", "valkey-server-8.0.1"]
command = [
"redis-server-6.2.11",
random.choice(servers),
f"--port {self.port}",
"--save ''",
"--appendonly no",
Expand Down
Loading