From dac1b0f3ca60b7a98a7cc51812045552336e4d2e Mon Sep 17 00:00:00 2001 From: Kostas Kyrimis Date: Mon, 7 Oct 2024 10:14:11 +0300 Subject: [PATCH] chore: allow rdb version 12 (#3860) We currently support rdb files up to version 11. This is a blocker for people who want to migrate to dragonfly with newer versions of the format. As of now, there is only v12 and it only includes the addition of RDB_OPCODE_SLOT_INFO. * adds support to load rdb files up to version 12 * reads and discards with a warning the contents of RDB_OPCODE_SLOT_INFO if found in the rdb file --------- Signed-off-by: kostas --- src/redis/rdb.h | 3 ++- src/server/rdb_load.cc | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/redis/rdb.h b/src/redis/rdb.h index 3b4814800..df0c4fdc1 100644 --- a/src/redis/rdb.h +++ b/src/redis/rdb.h @@ -38,7 +38,7 @@ /* The current RDB version. When the format changes in a way that is no longer * backward compatible this number gets incremented. */ -#define RDB_VERSION 11 +#define RDB_VERSION 12 /* We would like to serialize to version 9 such that our rdb files * can be loaded by redis version 6 (RDB_VERSION 9) */ @@ -110,6 +110,7 @@ /* Range 200-240 is used by Dragonfly specific opcodes */ /* Special RDB opcodes (saved/loaded with rdbSaveType/rdbLoadType). */ +#define RDB_OPCODE_SLOT_INFO 244 /* Individual slot info, such as slot id and size (cluster mode only). */ #define RDB_OPCODE_FUNCTION 246 /* engine data */ #define RDB_OPCODE_FUNCTION2 245 /* function library data */ #define RDB_OPCODE_FUNCTION_PRE_GA 246 /* old function library data for 7.0 rc1 and rc2 */ diff --git a/src/server/rdb_load.cc b/src/server/rdb_load.cc index 1e182374e..9d0558ad7 100644 --- a/src/server/rdb_load.cc +++ b/src/server/rdb_load.cc @@ -2307,6 +2307,16 @@ error_code RdbLoader::Load(io::Source* src) { continue; } + if (type == RDB_OPCODE_SLOT_INFO) { + [[maybe_unused]] uint64_t slot_id; + SET_OR_RETURN(LoadLen(nullptr), slot_id); + [[maybe_unused]] uint64_t slot_size; + SET_OR_RETURN(LoadLen(nullptr), slot_size); + [[maybe_unused]] uint64_t expires_slot_size; + SET_OR_RETURN(LoadLen(nullptr), expires_slot_size); + continue; + } + if (!rdbIsObjectTypeDF(type)) { return RdbError(errc::invalid_rdb_type); }