diff --git a/src/rdb.c b/src/rdb.c index d2c085d4d..00cc184af 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1146,6 +1146,8 @@ ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) { /* Save a module-specific aux value. */ RedisModuleIO io; int retval = rdbSaveType(rdb, RDB_OPCODE_MODULE_AUX); + if (retval == -1) return -1; + io.bytes += retval; /* Write the "module" identifier as prefix, so that we'll be able * to call the right module during loading. */ diff --git a/src/rdb.h b/src/rdb.h index 885cf49c6..f22fbecd1 100644 --- a/src/rdb.h +++ b/src/rdb.h @@ -149,6 +149,7 @@ robj *rdbLoadObject(int type, rio *rdb, sds key); void backgroundSaveDoneHandler(int exitcode, int bysignal); int rdbSaveKeyValuePair(rio *rdb, robj *key, robj *val, long long expiretime); ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt); +robj *rdbLoadCheckModuleValue(rio *rdb, char *modulename); robj *rdbLoadStringObject(rio *rdb); ssize_t rdbSaveStringObject(rio *rdb, robj *obj); ssize_t rdbSaveRawString(rio *rdb, unsigned char *s, size_t len); diff --git a/src/redis-check-rdb.c b/src/redis-check-rdb.c index 592feaf42..a9d110aa8 100644 --- a/src/redis-check-rdb.c +++ b/src/redis-check-rdb.c @@ -58,6 +58,7 @@ struct { #define RDB_CHECK_DOING_CHECK_SUM 5 #define RDB_CHECK_DOING_READ_LEN 6 #define RDB_CHECK_DOING_READ_AUX 7 +#define RDB_CHECK_DOING_READ_MODULE_AUX 8 char *rdb_check_doing_string[] = { "start", @@ -67,7 +68,8 @@ char *rdb_check_doing_string[] = { "read-object-value", "check-sum", "read-len", - "read-aux" + "read-aux", + "read-module-aux" }; char *rdb_type_string[] = { @@ -272,6 +274,21 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) { decrRefCount(auxkey); decrRefCount(auxval); continue; /* Read type again. */ + } else if (type == RDB_OPCODE_MODULE_AUX) { + /* AUX: Auxiliary data for modules. */ + uint64_t moduleid, when_opcode, when; + rdbstate.doing = RDB_CHECK_DOING_READ_MODULE_AUX; + if ((moduleid = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr; + if ((when_opcode = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr; + if ((when = rdbLoadLen(&rdb,NULL)) == RDB_LENERR) goto eoferr; + + char name[10]; + moduleTypeNameByID(name,moduleid); + rdbCheckInfo("MODULE AUX for: %s", name); + + robj *o = rdbLoadCheckModuleValue(&rdb,name); + decrRefCount(o); + continue; /* Read type again. */ } else { if (!rdbIsObjectType(type)) { rdbCheckError("Invalid object type: %d", type);