• zhaozhao.zz's avatar
    Set the correct id for tempDb (#12947) · 8d0156eb
    zhaozhao.zz authored
    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.
    8d0156eb
db.c 113 KB