From 6e9724cb6a8ff2bad4c8aeb591ee0d14120ca7af Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Tue, 22 Nov 2022 09:18:36 -0500 Subject: [PATCH] Add explicit error log message for AOF_TRUNCATED status when server load AOF file (#11484) Now, according to the comments, if the truncated file is not the last file, it will be considered as a fatal error. And the return code will updated to AOF_FAILED, then server will exit without any error message to the client. Similar to other error situations, this PR add an explicit error message for this case and make the client know clearly what happens. --- src/aof.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/aof.c b/src/aof.c index 2d1e1c441f..c5a47ab46e 100644 --- a/src/aof.c +++ b/src/aof.c @@ -1694,6 +1694,7 @@ int loadAppendOnlyFiles(aofManifest *am) { /* If the truncated file is not the last file, we consider this to be a fatal error. */ if (ret == AOF_TRUNCATED && !last_file) { ret = AOF_FAILED; + serverLog(LL_WARNING, "Fatal error: the truncated file is not the last file"); } if (ret == AOF_OPEN_ERR || ret == AOF_FAILED) { @@ -1724,8 +1725,10 @@ int loadAppendOnlyFiles(aofManifest *am) { * so empty incr AOF file doesn't count as a AOF_EMPTY result */ if (ret == AOF_EMPTY) ret = AOF_OK; + /* If the truncated file is not the last file, we consider this to be a fatal error. */ if (ret == AOF_TRUNCATED && !last_file) { ret = AOF_FAILED; + serverLog(LL_WARNING, "Fatal error: the truncated file is not the last file"); } if (ret == AOF_OPEN_ERR || ret == AOF_FAILED) {