Skip to content

Commit

Permalink
debug_sleep_after_fork sould be in seconds
Browse files Browse the repository at this point in the history
Signed-off-by: naglera <[email protected]>
  • Loading branch information
naglera committed Jun 30, 2024
1 parent cd46a33 commit fc840c1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void debugCommand(client *c) {
" In case RESET is provided the peak reset time will be restored to the default value",
"REPLYBUFFER RESIZING <0|1>",
" Enable or disable the reply buffer resize cron job",
"SLEEP-AFTER-FORK <micro seconds>",
"SLEEP-AFTER-FORK-SECONDS <seconds>",
" Stop the server's main process for <seconds> after forking.",
"WAIT-BEFORE-RDB-CLIENT-FREE <seconds>",
" Grace period in seconds for replica main connection to establish psync.",
Expand Down Expand Up @@ -996,7 +996,7 @@ void debugCommand(client *c) {
addReply(c, shared.ok);
} else if(!strcasecmp(c->argv[1]->ptr,"SLEEP-AFTER-FORK") &&
c->argc == 3) {
server.debug_sleep_after_fork = atoi(c->argv[2]->ptr);
server.debug_sleep_after_fork_seconds = atoi(c->argv[2]->ptr);
addReply(c,shared.ok);
} else if(!strcasecmp(c->argv[1]->ptr,"WAIT-BEFORE-RDB-CLIENT-FREE") &&
c->argc == 3) {
Expand Down
4 changes: 2 additions & 2 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ int startBgsaveForReplication(int mincapa, int req) {
/* Keep the page cache since it'll get used soon */
retval = rdbSaveBackground(req, server.rdb_filename, rsiptr, RDBFLAGS_REPLICATION | RDBFLAGS_KEEP_CACHE);
}
if (server.debug_sleep_after_fork) usleep(server.debug_sleep_after_fork);
if (server.debug_sleep_after_fork_seconds) sleep(server.debug_sleep_after_fork_seconds);
} else {
serverLog(LL_WARNING, "BGSAVE for replication: replication information not available, can't generate the RDB "
"file right now. Try later.");
Expand Down Expand Up @@ -3184,7 +3184,7 @@ void setupMainConnForPsync(connection *conn) {
}

if (server.repl_state == REPL_STATE_SEND_PSYNC) {
if (server.debug_sleep_after_fork) usleep(server.debug_sleep_after_fork);
if (server.debug_sleep_after_fork_seconds) sleep(server.debug_sleep_after_fork_seconds);
if (replicaTryPartialResynchronization(conn,0) == PSYNC_WRITE_ERROR) {
serverLog(LL_WARNING, "Aborting RDB connection sync. Write error.");
cancelReplicationHandshake(1);
Expand Down
2 changes: 1 addition & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ struct valkeyServer {
* use rdb connection for full syncs. */
int wait_before_rdb_client_free;/* Grace period in seconds for replica main connection
* to establish psync. */
int debug_sleep_after_fork; /* Debug param that force the main connection to
int debug_sleep_after_fork_seconds; /* Debug param that force the main connection to
* sleep for N seconds after fork() in repl. */
size_t repl_buffer_mem; /* The memory of replication buffer. */
list *repl_buffer_blocks; /* Replication buffers blocks list
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/repl-rdb-connection.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ start_server {tags {"repl rdb-connection external:skip"}} {
$master set key1 val1

$master config set repl-diskless-sync yes
$master debug sleep-after-fork [expr {5 * [expr {10 ** 6}]}];# Stop master after fork for 5 seconds
$master debug sleep-after-fork 5;# Stop master after fork for 5 seconds
$master config set repl-rdb-connection yes

$replica config set repl-rdb-connection yes
Expand Down Expand Up @@ -410,7 +410,7 @@ start_server {tags {"repl rdb-connection external:skip"}} {
$replica config set loglevel debug
$replica config set repl-timeout 10
# Stop replica after master fork for 5 seconds
$replica debug sleep-after-fork [expr {5 * [expr {10 ** 6}]}]
$replica debug sleep-after-fork 5

test "Test rdb-connection connection peering - replica able to establish psync" {
$replica slaveof $master_host $master_port
Expand Down Expand Up @@ -471,8 +471,8 @@ start_server {tags {"repl rdb-connection external:skip"}} {
$replica2 config set repl-timeout 10

# Stop replica after master fork for 2 seconds
$replica1 debug sleep-after-fork [expr {2 * [expr {10 ** 6}]}]
$replica2 debug sleep-after-fork [expr {2 * [expr {10 ** 6}]}]
$replica1 debug sleep-after-fork 2
$replica2 debug sleep-after-fork 2
test "Test rdb-connection connection peering - start with empty backlog (retrospect)" {
$replica1 slaveof $master_host $master_port
set res [wait_for_log_messages 0 {"*Add replica * repl-backlog is empty*"} $loglines 2000 1]
Expand Down Expand Up @@ -530,7 +530,7 @@ start_server {tags {"repl rdb-connection external:skip"}} {
# generate small db
populate 10 master 10
# Stop master main process after fork for 2 seconds
$master debug sleep-after-fork [expr {2 * [expr {10 ** 6}]}]
$master debug sleep-after-fork 2
$master debug wait-before-rdb-client-free 5

start_server {} {
Expand Down Expand Up @@ -628,7 +628,7 @@ start_server {tags {"repl rdb-connection external:skip"}} {
# generate small db
populate 10 master 10
# Stop master main process after fork for 1 seconds
$master debug sleep-after-fork [expr {2 * [expr {10 ** 6}]}]
$master debug sleep-after-fork 2
start_server {} {
set replica [srv 0 client]
set replica_host [srv 0 host]
Expand Down Expand Up @@ -662,7 +662,7 @@ start_server {tags {"repl rdb-connection external:skip"}} {
}

$replica slaveof no one
$replica debug sleep-after-fork [expr {2 * [expr {10 ** 6}]}]
$replica debug sleep-after-fork 2

$master debug populate 1000 master 100000
# Set master with a slow rdb generation, so that we can easily intercept loading
Expand Down

0 comments on commit fc840c1

Please sign in to comment.