Diskless replica: fix disklessLoadRestoreBackups() bug.
This commit is contained in:
parent
26c4e8a965
commit
ecd65cf9cf
@ -1138,16 +1138,16 @@ redisDb *disklessLoadMakeBackups(void) {
|
|||||||
*
|
*
|
||||||
* If the socket loading went wrong, we want to restore the old backups
|
* If the socket loading went wrong, we want to restore the old backups
|
||||||
* into the server databases. This function does just that in the case
|
* into the server databases. This function does just that in the case
|
||||||
* the 'count' argument (the number of DBs to replace) is non-zero.
|
* the 'restore' argument (the number of DBs to replace) is non-zero.
|
||||||
*
|
*
|
||||||
* When instead the loading succeeded we want just to free our old backups,
|
* When instead the loading succeeded we want just to free our old backups,
|
||||||
* in that case the funciton will do just that when 'count' is 0. */
|
* in that case the funciton will do just that when 'restore' is 0. */
|
||||||
void disklessLoadRestoreBackups(redisDb *backup, int count, int empty_db_flags)
|
void disklessLoadRestoreBackups(redisDb *backup, int restore, int empty_db_flags)
|
||||||
{
|
{
|
||||||
if (count) {
|
if (restore) {
|
||||||
/* Restore. */
|
/* Restore. */
|
||||||
emptyDbGeneric(server.db,-1,empty_db_flags,replicationEmptyDbCallback);
|
emptyDbGeneric(server.db,-1,empty_db_flags,replicationEmptyDbCallback);
|
||||||
for (int i=0; i<count; i++) {
|
for (int i=0; i<server.dbnum; i++) {
|
||||||
dictRelease(server.db[i].dict);
|
dictRelease(server.db[i].dict);
|
||||||
dictRelease(server.db[i].expires);
|
dictRelease(server.db[i].expires);
|
||||||
server.db[i] = backup[i];
|
server.db[i] = backup[i];
|
||||||
@ -1155,7 +1155,7 @@ void disklessLoadRestoreBackups(redisDb *backup, int count, int empty_db_flags)
|
|||||||
} else {
|
} else {
|
||||||
/* Delete. */
|
/* Delete. */
|
||||||
emptyDbGeneric(backup,-1,empty_db_flags,replicationEmptyDbCallback);
|
emptyDbGeneric(backup,-1,empty_db_flags,replicationEmptyDbCallback);
|
||||||
for (int i=0; i<count; i++) {
|
for (int i=0; i<server.dbnum; i++) {
|
||||||
dictRelease(backup[i].dict);
|
dictRelease(backup[i].dict);
|
||||||
dictRelease(backup[i].expires);
|
dictRelease(backup[i].expires);
|
||||||
}
|
}
|
||||||
@ -1382,7 +1382,7 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
rioFreeFd(&rdb, NULL);
|
rioFreeFd(&rdb, NULL);
|
||||||
if (server.repl_diskless_load == REPL_DISKLESS_LOAD_SWAPDB) {
|
if (server.repl_diskless_load == REPL_DISKLESS_LOAD_SWAPDB) {
|
||||||
/* Restore the backed up databases. */
|
/* Restore the backed up databases. */
|
||||||
disklessLoadRestoreBackups(diskless_load_backup,server.dbnum,
|
disklessLoadRestoreBackups(diskless_load_backup,1,
|
||||||
empty_db_flags);
|
empty_db_flags);
|
||||||
} else {
|
} else {
|
||||||
/* Remove the half-loaded data in case we started with
|
/* Remove the half-loaded data in case we started with
|
||||||
|
Loading…
x
Reference in New Issue
Block a user