From 8d0156eb186e60a32be3f0210d79f7289fcc6e66 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Mon, 22 Jan 2024 11:47:51 +0800 Subject: [PATCH] Set the correct id for tempDb (#12947) background: some modules need to know the `dbid` information, such as the function used during RDB loading: ``` robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) { .... moduleInitIOContext(io,mt,rdb,&keyobj,dbid); ``` However, during replication, the "tempDb" created for diskless RDB loading is not correctly set with the dbid. This leads to passing the wrong dbid to the `rdbLoadObject` function (as tempDb uses zcalloc, all ids are 0). ``` disklessLoadInitTempDb()->rdbLoadRioWithLoadingCtx()-> /* Read value */ val = rdbLoadObject(type,rdb,key,db->id,&error); ``` To fix it, set the correct ID (relative index) for the tempdb. --- src/db.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/db.c b/src/db.c index 50d6bd460..d40b1599a 100644 --- a/src/db.c +++ b/src/db.c @@ -763,6 +763,7 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) { redisDb *initTempDb(void) { redisDb *tempDb = zcalloc(sizeof(redisDb)*server.dbnum); for (int i=0; i