Skip to content

Commit fc390b4

Browse files
VGoshevsecwall
authored andcommitted
Add Valkey 9.1.0 support
1 parent 47bbf2c commit fc390b4

7 files changed

Lines changed: 209 additions & 222 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It uses a patched valkey version to make a cluster or sentinel-like setup less p
99

1010
## Limitations and requirements
1111

12-
* Patched valkey (patches for valkey 9.0 are included in this repo)
12+
* Patched valkey (patches for valkey 9.1 are included in this repo)
1313
* ZooKeeper as DCS
1414
* Single valkey instance per host
1515
* In clustered setup each shard must have it's own DCS prefix

valkey_patches/0001_Add_replication_pause.patch

Lines changed: 57 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/src/config.c b/src/config.c
2-
index d0158b2c4..f788aef6f 100644
2+
index fcbaee7e9..5c58b971f 100644
33
--- a/src/config.c
44
+++ b/src/config.c
5-
@@ -2588,6 +2588,25 @@ static int updateExtendedRedisCompat(const char **err) {
5+
@@ -2641,6 +2641,25 @@ static int updateExtendedRedisCompat(const char **err) {
66
return 1;
77
}
88

@@ -28,16 +28,16 @@ index d0158b2c4..f788aef6f 100644
2828
static int updateSighandlerEnabled(const char **err) {
2929
UNUSED(err);
3030
if (server.crashlog_enabled)
31-
@@ -3241,6 +3260,7 @@ standardConfig static_configs[] = {
32-
createBoolConfig("hide-user-data-from-log", NULL, MODIFIABLE_CONFIG, server.hide_user_data_from_log, 1, NULL, NULL),
31+
@@ -3312,6 +3331,7 @@ standardConfig static_configs[] = {
3332
createBoolConfig("lua-enable-insecure-api", "lua-enable-deprecated-api", MODIFIABLE_CONFIG | HIDDEN_CONFIG | PROTECTED_CONFIG, server.lua_enable_insecure_api, 0, NULL, updateLuaEnableInsecureApi),
3433
createBoolConfig("import-mode", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.import_mode, 0, NULL, NULL),
34+
createBoolConfig("io-threads-always-active", NULL, MODIFIABLE_CONFIG | HIDDEN_CONFIG, server.io_threads_always_active, 0, NULL, NULL),
3535
+ createBoolConfig("repl-paused", NULL, MODIFIABLE_CONFIG, server.repl_paused, 0, NULL, updateReplPaused),
3636

3737
/* String Configs */
3838
createStringConfig("aclfile", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, server.acl_filename, "", NULL, NULL),
3939
diff --git a/src/replication.c b/src/replication.c
40-
index 82ee9450f..25726c542 100644
40+
index 13cbc4183..c30560b3d 100644
4141
--- a/src/replication.c
4242
+++ b/src/replication.c
4343
@@ -59,7 +59,6 @@ void replicationResurrectProvisionalPrimary(void);
@@ -48,7 +48,7 @@ index 82ee9450f..25726c542 100644
4848
void replicationSteadyStateInit(void);
4949
void dualChannelSetupMainConnForPsync(connection *conn);
5050
void dualChannelSyncHandleRdbLoadCompletion(void);
51-
@@ -1069,7 +1068,7 @@ void syncCommand(client *c) {
51+
@@ -1115,7 +1114,7 @@ void syncCommand(client *c) {
5252

5353
/* Refuse SYNC requests if we are a replica but the link with our primary
5454
* is not ok... */
@@ -57,7 +57,7 @@ index 82ee9450f..25726c542 100644
5757
addReplyError(c, "-NOMASTERLINK Can't SYNC while not connected with my master");
5858
return;
5959
}
60-
@@ -5150,7 +5149,7 @@ void replicationCron(void) {
60+
@@ -5284,7 +5283,7 @@ void replicationCron(void) {
6161
}
6262

6363
/* Check if we should connect to a PRIMARY */
@@ -67,80 +67,26 @@ index 82ee9450f..25726c542 100644
6767
connectWithPrimary();
6868
}
6969
diff --git a/src/server.h b/src/server.h
70-
index 25f01a31e..95d31758e 100644
70+
index 351b1e43c..c8e03be25 100644
7171
--- a/src/server.h
7272
+++ b/src/server.h
73-
@@ -2117,6 +2117,7 @@ struct valkeyServer {
73+
@@ -2205,6 +2205,7 @@ struct valkeyServer {
7474
/* Synchronous replication. */
7575
list *clients_waiting_acks; /* Clients waiting in WAIT or WAITAOF. */
7676
int get_ack_from_replicas; /* If true we send REPLCONF GETACK. */
7777
+ int repl_paused; /* If true we don't try to connect to master */
7878
/* Limits */
7979
unsigned int maxclients; /* Max number of simultaneous clients */
8080
unsigned long long maxmemory; /* Max number of memory bytes to use */
81-
@@ -3116,6 +3117,8 @@ void updateFailoverStatus(void);
81+
@@ -3240,6 +3241,8 @@ void updateFailoverStatus(void);
8282
void abortFailover(const char *err);
8383
const char *getFailoverStateString(void);
8484
sds getReplicaPortString(void);
8585
+int cancelReplicationHandshake(int reconnect);
8686
+int replicaIsInHandshakeState(void);
8787
int sendCurrentOffsetToReplica(client *replica);
88+
int replicaRdbVersion(client *replica);
8889
void addRdbReplicaToPsyncWait(client *replica);
89-
void initClientReplicationData(client *c);
90-
diff --git a/tests/cluster/tests/99-yandex-cloud-patches.tcl b/tests/cluster/tests/99-yandex-cloud-patches.tcl
91-
new file mode 100644
92-
index 000000000..6d0c1007b
93-
--- /dev/null
94-
+++ b/tests/cluster/tests/99-yandex-cloud-patches.tcl
95-
@@ -0,0 +1,48 @@
96-
+# Test Yandex Cloud patches on cluster
97-
+
98-
+source "../tests/includes/init-tests.tcl"
99-
+
100-
+proc kill_clustered_redis {id} {
101-
+ set pid [get_instance_attrib redis $id pid]
102-
+
103-
+ stop_instance $pid
104-
+ set_instance_attrib redis $id pid -1
105-
+ set_instance_attrib redis $id link you_tried_to_talk_with_killed_instance
106-
+
107-
+ # Remove the PID from the list of pids to kill at exit.
108-
+ set ::pids [lsearch -all -inline -not -exact $::pids $pid]
109-
+}
110-
+
111-
+test "Create a 2 node cluster (1 master and 1 replica)" {
112-
+ create_cluster 1 1
113-
+}
114-
+
115-
+test "Cluster is up" {
116-
+ assert_cluster_state ok
117-
+}
118-
+
119-
+test "Instance #1 synced with the master" {
120-
+ wait_for_condition 1000 50 {
121-
+ [RI 1 master_link_status] eq {up}
122-
+ } else {
123-
+ fail "Instance #1 master link status is not up"
124-
+ }
125-
+}
126-
+
127-
+test "Replication pause on instance #1 works" {
128-
+ assert {[R 1 config set repl-paused yes] eq {OK}}
129-
+ wait_for_condition 1000 50 {
130-
+ [RI 1 master_link_status] eq {down}
131-
+ } else {
132-
+ fail "Instance #1 master link status is not down"
133-
+ }
134-
+}
135-
+
136-
+test "Replication resume on instance #1 works" {
137-
+ assert {[R 1 config set repl-paused no] eq {OK}}
138-
+ wait_for_condition 1000 50 {
139-
+ [RI 1 master_link_status] eq {up}
140-
+ } else {
141-
+ fail "Instance #1 master link status is not up"
142-
+ }
143-
+}
14490
diff --git a/tests/integration/yandex-cloud-patches.tcl b/tests/integration/yandex-cloud-patches.tcl
14591
new file mode 100644
14692
index 000000000..a2c9bb949
@@ -203,6 +149,49 @@ index 000000000..a2c9bb949
203149
+ }
204150
+ }
205151
+}
206-
--
207-
2.51.1
208-
152+
diff --git a/tests/unit/cluster/99-yandex-cloud-patches.tcl b/tests/unit/cluster/99-yandex-cloud-patches.tcl
153+
new file mode 100644
154+
index 000000000..ca4d2f5ec
155+
--- /dev/null
156+
+++ b/tests/unit/cluster/99-yandex-cloud-patches.tcl
157+
@@ -0,0 +1,40 @@
158+
+# Test Yandex Cloud patches on cluster
159+
+
160+
+start_cluster 1 2 {tags {external:skip cluster}} {
161+
+
162+
+test "Cluster is up" {
163+
+ wait_for_cluster_state ok
164+
+}
165+
+
166+
+test "Instance 0 is master and 1 is replica" {
167+
+ assert {[s 0 role] eq {master}}
168+
+ assert {[s -1 role] eq {slave}}
169+
+}
170+
+
171+
+test "Instance 1 synced with the master" {
172+
+ wait_for_condition 1000 50 {
173+
+ [s -1 master_link_status] eq {up}
174+
+ } else {
175+
+ fail "Instance 1 master link status is not up"
176+
+ }
177+
+}
178+
+
179+
+test "Replication pause on instance 1 works" {
180+
+ assert {[R 1 config set repl-paused yes] eq {OK}}
181+
+ wait_for_condition 1000 50 {
182+
+ [s -1 master_link_status] eq {down}
183+
+ } else {
184+
+ fail "Instance 1 master link status is not down"
185+
+ }
186+
+}
187+
+
188+
+test "Replication resume on instance 1 works" {
189+
+ assert {[R 1 config set repl-paused no] eq {OK}}
190+
+ wait_for_condition 1000 50 {
191+
+ [s -1 master_link_status] eq {up}
192+
+ } else {
193+
+ fail "Instance 1 master link status is not up"
194+
+ }
195+
+}
196+
+
197+
+}
Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c
2-
index ed4768bfe..cc6fb7d1d 100644
2+
index 63cfc13a0..10adddf5c 100644
33
--- a/src/cluster_legacy.c
44
+++ b/src/cluster_legacy.c
5-
@@ -7733,7 +7733,7 @@ int clusterCommandSpecial(client *c) {
5+
@@ -8120,7 +8120,7 @@ int clusterCommandSpecial(client *c) {
66
}
77

88
/* Can't replicate a replica. */
@@ -11,38 +11,24 @@ index ed4768bfe..cc6fb7d1d 100644
1111
addReplyError(c, "I can only replicate a master, not a replica.");
1212
return 1;
1313
}
14-
diff --git a/tests/cluster/tests/99-yandex-cloud-patches.tcl b/tests/cluster/tests/99-yandex-cloud-patches.tcl
15-
index 6d0c1007b..04b644128 100644
16-
--- a/tests/cluster/tests/99-yandex-cloud-patches.tcl
17-
+++ b/tests/cluster/tests/99-yandex-cloud-patches.tcl
18-
@@ -13,8 +13,8 @@ proc kill_clustered_redis {id} {
19-
set ::pids [lsearch -all -inline -not -exact $::pids $pid]
20-
}
21-
22-
-test "Create a 2 node cluster (1 master and 1 replica)" {
23-
- create_cluster 1 1
24-
+test "Create a 3 node cluster (1 master and 2 replicas)" {
25-
+ create_cluster 1 2
26-
}
27-
28-
test "Cluster is up" {
29-
@@ -38,6 +38,16 @@ test "Replication pause on instance #1 works" {
14+
diff --git a/tests/unit/cluster/99-yandex-cloud-patches.tcl b/tests/unit/cluster/99-yandex-cloud-patches.tcl
15+
index ca4d2f5ec..bb7844a92 100644
16+
--- a/tests/unit/cluster/99-yandex-cloud-patches.tcl
17+
+++ b/tests/unit/cluster/99-yandex-cloud-patches.tcl
18+
@@ -28,6 +28,16 @@ test "Replication pause on instance 1 works" {
3019
}
3120
}
3221

3322
+test "Replication cascade with paused instance works" {
3423
+ assert {[R 2 config set cluster-slave-no-failover yes] eq {OK}}
35-
+ assert {[R 2 cluster replicate [R 1 CLUSTER MYID]] eq {OK}}
24+
+ assert {[R 2 cluster replicate [R 1 cluster myid]] eq {OK}}
3625
+ wait_for_condition 1000 50 {
37-
+ [RI 2 master_link_status] eq {up}
26+
+ [s -2 master_link_status] eq {up}
3827
+ } else {
39-
+ fail "Instance #2 master link status is not up"
28+
+ fail "Instance 2 master link status is not up"
4029
+ }
4130
+}
4231
+
43-
test "Replication resume on instance #1 works" {
32+
test "Replication resume on instance 1 works" {
4433
assert {[R 1 config set repl-paused no] eq {OK}}
4534
wait_for_condition 1000 50 {
46-
--
47-
2.51.1
48-

valkey_patches/0003_Add_offline_mode.patch

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/src/config.c b/src/config.c
2-
index f788aef6f..aafa0616a 100644
2+
index 5c58b971f..0d852e730 100644
33
--- a/src/config.c
44
+++ b/src/config.c
5-
@@ -623,6 +623,8 @@ void loadServerConfigFromString(sds config) {
5+
@@ -631,6 +631,8 @@ void loadServerConfigFromString(sds config) {
66
if (server.hz < CONFIG_MIN_HZ) server.hz = CONFIG_MIN_HZ;
77
if (server.hz > CONFIG_MAX_HZ) server.hz = CONFIG_MAX_HZ;
88

@@ -11,7 +11,7 @@ index f788aef6f..aafa0616a 100644
1111
sdsfreesplitres(lines, totlines);
1212
reading_config_file = 0;
1313
return;
14-
@@ -3206,6 +3208,31 @@ static int applyClientMaxMemoryUsage(const char **err) {
14+
@@ -3276,6 +3278,31 @@ static int isValidDbHashSeed(sds val, const char **err) {
1515
return 1;
1616
}
1717

@@ -43,7 +43,7 @@ index f788aef6f..aafa0616a 100644
4343
standardConfig static_configs[] = {
4444
/* Bool configs */
4545
createBoolConfig("rdbchecksum", NULL, IMMUTABLE_CONFIG, server.rdb_checksum, 1, NULL, NULL),
46-
@@ -3461,6 +3488,7 @@ standardConfig static_configs[] = {
46+
@@ -3536,6 +3563,7 @@ standardConfig static_configs[] = {
4747
createSpecialConfig("rdma-bind", NULL, MODIFIABLE_CONFIG | MULTI_ARG_CONFIG, setConfigRdmaBindOption, getConfigRdmaBindOption, rewriteConfigRdmaBindOption, applyRdmaBind),
4848
createSpecialConfig("replicaof", "slaveof", IMMUTABLE_CONFIG | MULTI_ARG_CONFIG, setConfigReplicaOfOption, getConfigReplicaOfOption, rewriteConfigReplicaOfOption, NULL),
4949
createSpecialConfig("latency-tracking-info-percentiles", NULL, MODIFIABLE_CONFIG | MULTI_ARG_CONFIG, setConfigLatencyTrackingInfoPercentilesOutputOption, getConfigLatencyTrackingInfoPercentilesOutputOption, rewriteConfigLatencyTrackingInfoPercentilesOutputOption, NULL),
@@ -52,10 +52,10 @@ index f788aef6f..aafa0616a 100644
5252
/* NULL Terminator, this is dropped when we convert to the runtime array. */
5353
{NULL},
5454
diff --git a/src/server.c b/src/server.c
55-
index 46a20d1ae..860a3cb41 100644
55+
index e018a6182..7594a672e 100644
5656
--- a/src/server.c
5757
+++ b/src/server.c
58-
@@ -2664,9 +2664,15 @@ int listenToPort(connListener *sfd) {
58+
@@ -2717,9 +2717,15 @@ int listenToPort(connListener *sfd) {
5959
int j;
6060
int port = sfd->port;
6161
char **bindaddr = sfd->bindaddr;
@@ -72,7 +72,7 @@ index 46a20d1ae..860a3cb41 100644
7272

7373
for (j = 0; j < sfd->bindaddr_count; j++) {
7474
char *addr = bindaddr[j];
75-
@@ -6865,8 +6871,8 @@ void dismissMemoryInChild(void) {
75+
@@ -7176,8 +7182,8 @@ void dismissMemoryInChild(void) {
7676
/* madvise(MADV_DONTNEED) may not work if Transparent Huge Pages is enabled. */
7777
if (server.thp_enabled) return;
7878

@@ -83,20 +83,11 @@ index 46a20d1ae..860a3cb41 100644
8383
#if defined(USE_JEMALLOC) && defined(__linux__)
8484
listIter li;
8585
listNode *ln;
86-
@@ -7311,7 +7317,7 @@ __attribute__((weak)) int main(int argc, char **argv) {
87-
}
88-
if (server.sentinel_mode) sentinelCheckConfigFile();
89-
90-
- /* Do system checks */
91-
+ /* Do system checks */
92-
#ifdef __linux__
93-
linuxMemoryWarnings();
94-
sds err_msg = NULL;
9586
diff --git a/src/server.h b/src/server.h
96-
index 95d31758e..a82eabd26 100644
87+
index c8e03be25..d941665ea 100644
9788
--- a/src/server.h
9889
+++ b/src/server.h
99-
@@ -2118,6 +2118,9 @@ struct valkeyServer {
90+
@@ -2206,6 +2206,9 @@ struct valkeyServer {
10091
list *clients_waiting_acks; /* Clients waiting in WAIT or WAITAOF. */
10192
int get_ack_from_replicas; /* If true we send REPLCONF GETACK. */
10293
int repl_paused; /* If true we don't try to connect to master */
@@ -135,6 +126,3 @@ index 000000000..b8c3ba453
135126
+ }
136127
+ }
137128
+}
138-
--
139-
2.51.1
140-

0 commit comments

Comments
 (0)