Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dual channel replication should not update lastbgsave_status when transfer error #811

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3450,10 +3450,9 @@ static void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) {
if (!bysignal && exitcode == 0) {
serverLog(LL_NOTICE, "Background RDB transfer terminated with success");
} else if (!bysignal && exitcode != 0) {
serverLog(LL_WARNING, "Background transfer error");
server.lastbgsave_status = C_ERR;
enjoy-binbin marked this conversation as resolved.
Show resolved Hide resolved
serverLog(LL_WARNING, "Background RDB transfer error");
} else {
serverLog(LL_WARNING, "Background transfer terminated by signal %d", bysignal);
serverLog(LL_WARNING, "Background RDB transfer terminated by signal %d", bysignal);
}
if (server.rdb_child_exit_pipe != -1) close(server.rdb_child_exit_pipe);
if (server.rdb_pipe_read > 0) {
Expand Down
29 changes: 8 additions & 21 deletions tests/integration/dual-channel-replication.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -870,18 +870,15 @@ start_server {tags {"dual-channel-replication external:skip"}} {
$primary debug log "killing replica main connection"
set replica_main_conn_id [get_client_id_by_last_cmd $primary "psync"]
assert {$replica_main_conn_id != ""}
set loglines [count_log_lines -1]
$primary client kill id $replica_main_conn_id
# Wait for primary to abort the sync
wait_for_condition 50 1000 {
[string match {*replicas_waiting_psync:0*} [$primary info replication]]
} else {
fail "Primary did not free repl buf block after sync failure"
}
wait_for_condition 1000 10 {
[s -1 rdb_last_bgsave_status] eq "err"
} else {
fail "bgsave did not stop in time"
}
wait_for_log_messages -1 {"*Background RDB transfer error*"} $loglines 1000 10
}

test "Test dual channel replication slave of no one after main conn kill" {
Expand All @@ -907,14 +904,10 @@ start_server {tags {"dual-channel-replication external:skip"}} {
$primary debug log "killing replica rdb connection"
set replica_rdb_channel_id [get_client_id_by_last_cmd $primary "sync"]
assert {$replica_rdb_channel_id != ""}
set loglines [count_log_lines -1]
$primary client kill id $replica_rdb_channel_id
# Wait for primary to abort the sync
wait_for_condition 1000 10 {
[s -1 rdb_bgsave_in_progress] eq 0 &&
[s -1 rdb_last_bgsave_status] eq "err"
} else {
fail "Primary should abort sync"
}
wait_for_log_messages -1 {"*Background RDB transfer error*"} $loglines 1000 10
}

test "Test dual channel replication slave of no one after rdb conn kill" {
Expand Down Expand Up @@ -1051,18 +1044,15 @@ start_server {tags {"dual-channel-replication external:skip"}} {
$primary debug log "killing replica rdb connection"
set replica_rdb_channel_id [get_client_id_by_last_cmd $primary "sync"]
assert {$replica_rdb_channel_id != ""}
set loglines [count_log_lines -1]
$primary client kill id $replica_rdb_channel_id
# Wait for primary to abort the sync
wait_for_condition 50 1000 {
[string match {*replicas_waiting_psync:0*} [$primary info replication]]
} else {
fail "Primary did not free repl buf block after sync failure"
}
wait_for_condition 1000 10 {
[s -1 rdb_last_bgsave_status] eq "err"
} else {
fail "bgsave did not stop in time"
}
wait_for_log_messages -1 {"*Background RDB transfer error*"} $loglines 1000 10
# Replica should retry
verify_replica_online $primary 0 500
stop_write_load $load_handle
Expand All @@ -1089,18 +1079,15 @@ start_server {tags {"dual-channel-replication external:skip"}} {
$primary debug log "killing replica main connection"
set replica_main_conn_id [get_client_id_by_last_cmd $primary "sync"]
assert {$replica_main_conn_id != ""}
set loglines [count_log_lines -1]
$primary client kill id $replica_main_conn_id
# Wait for primary to abort the sync
wait_for_condition 50 1000 {
[string match {*replicas_waiting_psync:0*} [$primary info replication]]
} else {
fail "Primary did not free repl buf block after sync failure"
}
wait_for_condition 1000 10 {
[s -1 rdb_last_bgsave_status] eq "err"
} else {
fail "bgsave did not stop in time"
}
wait_for_log_messages -1 {"*Background RDB transfer error*"} $loglines 1000 10
# Replica should retry
verify_replica_online $primary 0 500
stop_write_load $load_handle
Expand Down
Loading