From a3ae2ed37bee8158c25cc8707c5c2cdfc1e974d7 Mon Sep 17 00:00:00 2001 From: Binbin Date: Sun, 10 Dec 2023 16:40:15 +0800 Subject: [PATCH] Remove dead code around should_expand_db (#12767) when dbExpand is called from rdb.c with try_expand set to 0, it will either panic panic on OOM, or be non-fatal (should not fail RDB loading) At the same time, the log text has been slightly adjusted to make it more unified. --- src/db.c | 4 ++-- src/rdb.c | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/db.c b/src/db.c index 6cef5d734..0059af78a 100644 --- a/src/db.c +++ b/src/db.c @@ -2228,11 +2228,11 @@ int dbExpand(const redisDb *db, uint64_t db_size, dbKeyType keyType, int try_exp } int result = try_expand ? dictTryExpand(d, db_size) : dictExpand(d, db_size); if (try_expand && result == DICT_ERR) { - serverLog(LL_WARNING, "Dict expansion failed for type :%s slot: %d", + serverLog(LL_WARNING, "Dict expansion failed for db type: %s, slot: %d", keyType == DB_MAIN ? "main" : "expires", i); return C_ERR; } else if (result == DICT_ERR) { - serverLog(LL_DEBUG, "Dict expansion skipped for type :%s slot: %d", + serverLog(LL_DEBUG, "Dict expansion skipped for db type: %s, slot: %d", keyType == DB_MAIN ? "main" : "expires", i); } } diff --git a/src/rdb.c b/src/rdb.c index 88b455153..b50ea7867 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -3264,14 +3264,8 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin /* If there is no slot info, it means that it's either not cluster mode or we are trying to load legacy RDB file. * In this case we want to estimate number of keys per slot and resize accordingly. */ if (should_expand_db) { - if (dbExpand(db, db_size, DB_MAIN, 0) == C_ERR) { - serverLog(LL_WARNING, "OOM in dict expand of main dict"); - return C_ERR; - } - if (dbExpand(db, expires_size, DB_EXPIRES, 0) == C_ERR) { - serverLog(LL_WARNING, "OOM in dict expand of expire dict"); - return C_ERR; - } + dbExpand(db, db_size, DB_MAIN, 0); + dbExpand(db, expires_size, DB_EXPIRES, 0); should_expand_db = 0; }