From 755b51a42c7b0dd570b80d9893ae26d94d71e39c Mon Sep 17 00:00:00 2001 From: Binbin Date: Thu, 23 Jun 2022 23:40:20 +0800 Subject: [PATCH] When dirCreateIfMissing or openNewIncrAofForAppend fail, set aof_lastbgrewrite_status to err (#10775) It will be displayed in the `aof_last_bgrewrite_status` field of the INFO command. --- src/aof.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/aof.c b/src/aof.c index 55d9990bc..c7bde0ac5 100644 --- a/src/aof.c +++ b/src/aof.c @@ -2408,6 +2408,7 @@ int rewriteAppendOnlyFileBackground(void) { if (dirCreateIfMissing(server.aof_dirname) == -1) { serverLog(LL_WARNING, "Can't open or create append-only dir %s: %s", server.aof_dirname, strerror(errno)); + server.aof_lastbgrewrite_status = C_ERR; return C_ERR; } @@ -2415,7 +2416,10 @@ int rewriteAppendOnlyFileBackground(void) { * feedAppendOnlyFile() to issue a SELECT command. */ server.aof_selected_db = -1; flushAppendOnlyFile(1); - if (openNewIncrAofForAppend() != C_OK) return C_ERR; + if (openNewIncrAofForAppend() != C_OK) { + server.aof_lastbgrewrite_status = C_ERR; + return C_ERR; + } server.stat_aof_rewrites++; if ((childpid = redisFork(CHILD_TYPE_AOF)) == 0) { char tmpfile[256];