From ae9764ea0a6bb3cfeff9baae2d4fd748a53d1864 Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 7 Jun 2022 22:38:31 +0800 Subject: [PATCH] Increment the stat_rdb_saves counter in SAVE command (#10827) Currently, we only increment stat_rdb_saves in rdbSaveBackground, we should also increment it in the SAVE command. We concluded there's no need to increment when: 1. saving a base file for an AOF 2. when saving an empty rdb file to delete an old one 3. when saving to sockets (not creating a persistence / snapshot file) The stat counter was introduced in #10178 * fix a wrong comment in startSaving --- src/rdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rdb.c b/src/rdb.c index 1faecd2f3..141677c30 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -2746,7 +2746,7 @@ void stopLoading(int success) { } void startSaving(int rdbflags) { - /* Fire the persistence modules end event. */ + /* Fire the persistence modules start event. */ int subevent; if (rdbflags & RDBFLAGS_AOF_PREAMBLE && getpid() != server.pid) subevent = REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START; @@ -3479,6 +3479,9 @@ void saveCommand(client *c) { addReplyError(c,"Background save already in progress"); return; } + + server.stat_rdb_saves++; + rdbSaveInfo rsi, *rsiptr; rsiptr = rdbPopulateSaveInfo(&rsi); if (rdbSave(SLAVE_REQ_NONE,server.rdb_filename,rsiptr) == C_OK) {