Call emptyData when disk-based sync rdbLoad fails (#12510)

We doing this in diskless on-empty-db mode, when diskless
loading fails, we will call emptyData to remove the half-loaded
data in case we started with an empty replica.

Now when a disk-based sync rdbLoad fails, we will call emptyData
too in case it loads partially incomplete data.

when the replica attempts another re-sync, it'll empty the dataset
again anyway, so this affects two things:
1. memory consumption in the time gap until the next rdb loading begins
2. if the unsynced replica is for some reason promoted, it would have kept
  the partial dataset instead of being empty.
This commit is contained in:
Binbin 2024-01-18 22:28:52 +08:00 committed by GitHub
parent 29e6245a05
commit 0e5a4a27ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -2240,6 +2240,10 @@ void readSyncBulkPayload(connection *conn) {
"disabled");
bg_unlink(server.rdb_filename);
}
/* If disk-based RDB loading fails, remove the half-loaded dataset. */
emptyData(-1, empty_db_flags, replicationEmptyDbCallback);
/* Note that there's no point in restarting the AOF on sync failure,
it'll be restarted when sync succeeds or replica promoted. */
return;