Describe the bug
I use redis6.0. However I found that redis slave does not always use partial REPLICA after restarted.
To reproduce
- start aof-use-rdb-preamble in redis.conf aof-use-rdb-preamble yes 2.restart redis6.0 then the log is written that:
134:S 06 May 2022 20:05:19.957 * Connecting to MASTER 127.0.0.1:6379 134:S 06 May 2022 20:05:19.959 * MASTER <-> REPLICA sync started 134:S 06 May 2022 20:05:19.962 * Non blocking connect for SYNC fired the event. 134:S 06 May 2022 20:05:19.965 * Master replied to PING, replication can continue... 134:S 06 May 2022 20:05:19.968 * Partial resynchronization not possible (no cached master) 134:S 06 May 2022 20:05:25.224 * Full resync from master: 996dd0912cf1949fcd763d8db34897f6073c66da:191 134:S 06 May 2022 20:05:25.572 * MASTER <-> REPLICA sync: receiving streamed RDB from master with EOF to disk 134:S 06 May 2022 20:05:25.575 * MASTER <-> REPLICA sync: Flushing old data 134:S 06 May 2022 20:05:25.580 * MASTER <-> REPLICA sync: Loading DB in memory 134:S 06 May 2022 20:05:25.584 * Loading RDB produced by version 6.0.16 134:S 06 May 2022 20:05:25.586 * RDB age 0 seconds 134:S 06 May 2022 20:05:25.588 * RDB memory usage when created 1.49 Mb 134:S 06 May 2022 20:05:25.591 * MASTER <-> REPLICA sync: Finished with success
Expected behavior
I hope that slave redis will use partial REPLICA once restarted.
Additional information
I found why the aof file will not use partial replication. Because in aof.c does not save the redis slave info. see below: function: rewriteAppendOnlyFile() the last para in rdbSaveRio is null. So why we pass null into it? Is there any meaningful thought?
`int rewriteAppendOnlyFile(char *filename) { //do something
if (server.aof_use_rdb_preamble) {
int error;
if (rdbSaveRio(&aof,&error,RDBFLAGS_AOF_PREAMBLE,NULL) == C_ERR) {
errno = error;
goto werr;
}
} else {
if (rewriteAppendOnlyFileRio(&aof) == C_ERR) goto werr;
}
}`
Comment From: oranagra
this topic is tracked in #9796