Skip to content

Commit cd9514f

Browse files
committed
Fix failure to merge databases on active replica sync, due to bad merge with Redis 6
1 parent f111c23 commit cd9514f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/replication.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,6 @@ void readSyncBulkPayload(connection *conn) {
20692069
*
20702070
* 2. Or when we are done reading from the socket to the RDB file, in
20712071
* such case we want just to read the RDB file in memory. */
2072-
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Flushing old data");
20732072

20742073
/* We need to stop any AOF rewriting child before flusing and parsing
20752074
* the RDB, otherwise we'll create a copy-on-write disaster. */
@@ -2089,7 +2088,10 @@ void readSyncBulkPayload(connection *conn) {
20892088
* (Where disklessLoadMakeBackups left server.db empty) because we
20902089
* want to execute all the auxiliary logic of emptyDb (Namely,
20912090
* fire module events) */
2092-
emptyDb(-1,empty_db_flags,replicationEmptyDbCallback);
2091+
if (!fUpdate) {
2092+
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Flushing old data");
2093+
emptyDb(-1,empty_db_flags,replicationEmptyDbCallback);
2094+
}
20932095

20942096
/* Before loading the DB into memory we need to delete the readable
20952097
* handler, otherwise it will get called recursively since

tests/integration/replication-active.tcl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,18 @@ start_server {tags {"active-repl"} overrides {active-replica yes}} {
237237
}
238238
}
239239
}
240+
241+
start_server {tags {"active-repl"} overrides {active-replica yes}} {
242+
set slave [srv 0 client]
243+
set slave_host [srv 0 host]
244+
set slave_port [srv 0 port]
245+
start_server {tags {"active-repl"} overrides { active-replica yes}} {
246+
r set testkeyB bar
247+
test {Active Replica Merges Database On Sync} {
248+
$slave set testkeyA foo
249+
r replicaof $slave_host $slave_port
250+
after 1000
251+
assert_equal 2 [r dbsize]
252+
}
253+
}
254+
}

0 commit comments

Comments
 (0)