Fix failure to merge databases on active replica sync, due to bad merge with Redis 6

Former-commit-id: cd9514f4c8624932df2ec60ae3c2244899844aa6
This commit is contained in:
John Sully 2020-07-12 01:13:22 +00:00
parent 3af243a447
commit 785779ee40
2 changed files with 19 additions and 2 deletions

View File

@ -2069,7 +2069,6 @@ void readSyncBulkPayload(connection *conn) {
* *
* 2. Or when we are done reading from the socket to the RDB file, in * 2. Or when we are done reading from the socket to the RDB file, in
* such case we want just to read the RDB file in memory. */ * such case we want just to read the RDB file in memory. */
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Flushing old data");
/* We need to stop any AOF rewriting child before flusing and parsing /* We need to stop any AOF rewriting child before flusing and parsing
* the RDB, otherwise we'll create a copy-on-write disaster. */ * the RDB, otherwise we'll create a copy-on-write disaster. */
@ -2089,7 +2088,10 @@ void readSyncBulkPayload(connection *conn) {
* (Where disklessLoadMakeBackups left server.db empty) because we * (Where disklessLoadMakeBackups left server.db empty) because we
* want to execute all the auxiliary logic of emptyDb (Namely, * want to execute all the auxiliary logic of emptyDb (Namely,
* fire module events) */ * fire module events) */
emptyDb(-1,empty_db_flags,replicationEmptyDbCallback); if (!fUpdate) {
serverLog(LL_NOTICE, "MASTER <-> REPLICA sync: Flushing old data");
emptyDb(-1,empty_db_flags,replicationEmptyDbCallback);
}
/* Before loading the DB into memory we need to delete the readable /* Before loading the DB into memory we need to delete the readable
* handler, otherwise it will get called recursively since * handler, otherwise it will get called recursively since

View File

@ -237,3 +237,18 @@ start_server {tags {"active-repl"} overrides {active-replica yes}} {
} }
} }
} }
start_server {tags {"active-repl"} overrides {active-replica yes}} {
set slave [srv 0 client]
set slave_host [srv 0 host]
set slave_port [srv 0 port]
start_server {tags {"active-repl"} overrides { active-replica yes}} {
r set testkeyB bar
test {Active Replica Merges Database On Sync} {
$slave set testkeyA foo
r replicaof $slave_host $slave_port
after 1000
assert_equal 2 [r dbsize]
}
}
}