From 66bed3f220d3ae73449b6b9f89ae616e42eff2e4 Mon Sep 17 00:00:00 2001 From: Binbin Date: Thu, 9 Feb 2023 13:57:19 +0800 Subject: [PATCH] When DEBUG LOADAOF fails, return an error instead of exiting (#11790) Return an error when loadAppendOnlyFiles fails instead of exiting. DEBUF LOADAOF command is only meant to be used by the test suite, and only by tests that generated an AOF file first. So this change is ok (considering that the caller is likely to catch this error and die). This actually revert part of the code in #9012, and now DEBUG LOADAOF behaves the same as DEBUG RELOAD (returns an error when the load fails). Plus remove a `after 2000` in a test, which can save times (looks like copy paste error). --- src/debug.c | 6 ++++-- tests/unit/expire.tcl | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/debug.c b/src/debug.c index e00263d8e..29e507e06 100644 --- a/src/debug.c +++ b/src/debug.c @@ -585,9 +585,11 @@ NULL aofLoadManifestFromDisk(); aofDelHistoryFiles(); int ret = loadAppendOnlyFiles(server.aof_manifest); - if (ret != AOF_OK && ret != AOF_EMPTY) - exit(1); unprotectClient(c); + if (ret != AOF_OK && ret != AOF_EMPTY) { + addReplyError(c, "Error trying to load the AOF files, check server logs."); + return; + } server.dirty = 0; /* Prevent AOF / replication */ serverLog(LL_WARNING,"Append Only File loaded by DEBUG LOADAOF"); addReply(c,shared.ok); diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl index 62ade68f5..2b0fc22e9 100644 --- a/tests/unit/expire.tcl +++ b/tests/unit/expire.tcl @@ -603,9 +603,9 @@ start_server {tags {"expire"}} { } {-1} test {GETEX use of PERSIST option should remove TTL after loadaof} { + r config set appendonly yes r set foo bar EX 100 r getex foo PERSIST - after 2000 r debug loadaof r ttl foo } {-1} {needs:debug}