Skip to content

Commit

Permalink
Unprotect rdb channel when bgsave child fails in dual channel replica…
Browse files Browse the repository at this point in the history
…tion (#1297)

If bgsaveerr is error, there is no need to protect the rdb channel.
The impact of this may be that when bgsave fails, we will protect
the rdb channel for 60s. It may occupy the reference of the repl
buf block, making it impossible to recycle it until we free the
client due to COB or free the client after 60s.

We kept the RDB channel open as long as the replica hadn't established
a main connection, even if the snapshot process failed. There is no
value in keeping the RDB client in this case.

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin authored Nov 15, 2024
1 parent 92181b6 commit 86f33ea
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,8 @@ void updateReplicasWaitingBgsave(int bgsaveerr, int type) {
struct valkey_stat buf;

if (bgsaveerr != C_OK) {
/* If bgsaveerr is error, there is no need to protect the rdb channel. */
replica->flag.protected_rdb_channel = 0;
freeClientAsync(replica);
serverLog(LL_WARNING, "SYNC failed. BGSAVE child returned an error");
continue;
Expand Down

0 comments on commit 86f33ea

Please sign in to comment.