Update test to handle forkless bgsave
Former-commit-id: fc8c6de8252e6b802688413050f1a823093d0a1d
This commit is contained in:
parent
b20ab1fd21
commit
52c1d17127
@ -58,6 +58,8 @@ typedef ucontext_t sigcontext_t;
|
||||
|
||||
int g_fInCrash = false;
|
||||
|
||||
void getTempFileName(char tmpfile[], int tmpfileNum);
|
||||
|
||||
/* ================================= Debugging ============================== */
|
||||
|
||||
/* Compute the sha1 of string at 's' with 'len' bytes long.
|
||||
@ -825,6 +827,10 @@ NULL
|
||||
c->flags &= ~(CLIENT_MASTER | CLIENT_MASTER_FORCE_REPLY);
|
||||
}
|
||||
addReply(c, shared.ok);
|
||||
} else if (!strcasecmp(szFromObj(c->argv[1]), "get-temp-file") && c->argc == 2) {
|
||||
char tmpfile[256];
|
||||
getTempFileName(tmpfile, g_pserver->rdbThreadVars.tmpfileNum);
|
||||
addReplyBulkCString(c, tmpfile);
|
||||
} else if (!strcasecmp(szFromObj(c->argv[1]),"truncate-repl-backlog") && c->argc == 2) {
|
||||
g_pserver->repl_backlog_idx = 0;
|
||||
g_pserver->repl_backlog_off = g_pserver->master_repl_offset+1;
|
||||
|
17
src/rdb.cpp
17
src/rdb.cpp
@ -1637,12 +1637,7 @@ int rdbSaveBackground(rdbSaveInfo *rsi) {
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
/* Note that we may call this function in signal handle 'sigShutdownHandler',
|
||||
* so we need guarantee all functions we call are async-signal-safe.
|
||||
* If we call this function from signal handle, we won't call bg_unlik that
|
||||
* is not async-signal-safe. */
|
||||
void rdbRemoveTempFile(int tmpfileNum, int from_signal) {
|
||||
char tmpfile[256];
|
||||
void getTempFileName(char tmpfile[], int tmpfileNum) {
|
||||
char pid[32];
|
||||
char tmpfileNumString[214];
|
||||
|
||||
@ -1654,6 +1649,16 @@ void rdbRemoveTempFile(int tmpfileNum, int from_signal) {
|
||||
strcpy(tmpfile+5+pid_len, "-");
|
||||
strncpy(tmpfile+5+pid_len+1, tmpfileNumString, tmpfileNum_len);
|
||||
strcpy(tmpfile+5+pid_len+1+tmpfileNum_len, ".rdb");
|
||||
}
|
||||
|
||||
/* Note that we may call this function in signal handle 'sigShutdownHandler',
|
||||
* so we need guarantee all functions we call are async-signal-safe.
|
||||
* If we call this function from signal handle, we won't call bg_unlik that
|
||||
* is not async-signal-safe. */
|
||||
void rdbRemoveTempFile(int tmpfileNum, int from_signal) {
|
||||
char tmpfile[256];
|
||||
|
||||
getTempFileName(tmpfile, tmpfileNum);
|
||||
|
||||
if (from_signal) {
|
||||
/* bg_unlink is not async-signal-safe, but in this case we don't really
|
||||
|
@ -10,8 +10,8 @@ start_server {tags {"shutdown"}} {
|
||||
r bgsave
|
||||
after 100
|
||||
set dir [lindex [r config get dir] 1]
|
||||
set child_pid [get_child_pid 0]
|
||||
set temp_rdb [file join [lindex [r config get dir] 1] temp-${child_pid}.rdb]
|
||||
set tmpfile [r debug get-temp-file]
|
||||
set temp_rdb [file join [lindex [r config get dir] 1] $tmpfile]
|
||||
# Temp rdb must be existed
|
||||
assert {[file exists $temp_rdb]}
|
||||
|
||||
@ -34,7 +34,8 @@ start_server {tags {"shutdown"}} {
|
||||
r config set rdb-key-save-delay 100000
|
||||
|
||||
set pid [s process_id]
|
||||
set temp_rdb [file join [lindex [r config get dir] 1] temp-${pid}.rdb]
|
||||
set tmpfile [r debug get-temp-file]
|
||||
set temp_rdb [file join [lindex [r config get dir] 1] $tmpfile]
|
||||
|
||||
# trigger a shutdown which will save an rdb
|
||||
exec kill -SIGINT $pid
|
||||
|
Loading…
x
Reference in New Issue
Block a user