diff --git a/src/config.cpp b/src/config.cpp index f7609feb7..fea7b3076 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -2537,6 +2537,7 @@ standardConfig configs[] = { createBoolConfig("io-threads-do-reads", NULL, IMMUTABLE_CONFIG, fDummy, 0, NULL, NULL), createBoolConfig("time-thread-priority", NULL, IMMUTABLE_CONFIG, cserver.time_thread_priority, 0, NULL, NULL), createBoolConfig("prefetch-enabled", NULL, MODIFIABLE_CONFIG, g_pserver->prefetch_enabled, 1, NULL, NULL), + createBoolConfig("allow-rdb-resize-op", NULL, MODIFIABLE_CONFIG, g_pserver->allowRdbResizeOp, 1, NULL, NULL), /* String Configs */ createStringConfig("aclfile", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, g_pserver->acl_filename, "", NULL, NULL), diff --git a/src/rdb.cpp b/src/rdb.cpp index ac35c219c..8c03fa60b 100644 --- a/src/rdb.cpp +++ b/src/rdb.cpp @@ -2699,9 +2699,11 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) { goto eoferr; if ((expires_size = rdbLoadLen(rdb,NULL)) == RDB_LENERR) goto eoferr; - wqueue.enqueue([dbCur, db_size]{ - dbCur->expand(db_size); - }); + if (g_pserver->allowRdbResizeOp) { + wqueue.enqueue([dbCur, db_size]{ + dbCur->expand(db_size); + }); + } continue; /* Read next opcode. */ } else if (type == RDB_OPCODE_AUX) { /* AUX: generic string-string fields. Use to add state to RDB diff --git a/src/server.h b/src/server.h index 9d3e70197..65b1a4a5b 100644 --- a/src/server.h +++ b/src/server.h @@ -2161,6 +2161,7 @@ struct redisServer { sds aof_child_diff; /* AOF diff accumulator child side. */ int aof_rewrite_pending = 0; /* is a call to aofChildWriteDiffData already queued? */ /* RDB persistence */ + int allowRdbResizeOp; /* Debug situations we may want rehash to be ocurring, so ignore resize */ long long dirty; /* Changes to DB from the last save */ long long dirty_before_bgsave; /* Used to restore dirty on failed BGSAVE */ struct _rdbThreadVars diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl index 58dc6c968..29af7af42 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -189,3 +189,15 @@ test {client freed during loading} { exec kill [srv 0 pid] } } + +test {repeated load} { + start_server [list overrides [list server-threads 3 allow-rdb-resize-op no]] { + r debug populate 500000 key 1000 + + set digest [r debug digest] + for {set j 0} {$j < 10} {incr j} { + r debug reload + assert_equal $digest [r debug digest] + } + } +}