CG: fix RDB saving when there are no consumer groups.

This commit is contained in:
antirez 2018-02-18 23:13:41 +01:00
parent 267f7f2c97
commit 13ff7bc3ef

View File

@ -894,9 +894,11 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
* type, so serialize every consumer group. */ * type, so serialize every consumer group. */
/* Save the number of groups. */ /* Save the number of groups. */
if ((n = rdbSaveLen(rdb,raxSize(s->cgroups))) == -1) return -1; size_t num_cgroups = s->cgroups ? raxSize(s->cgroups) : 0;
if ((n = rdbSaveLen(rdb,num_cgroups)) == -1) return -1;
nwritten += n; nwritten += n;
if (num_cgroups) {
/* Serialize each consumer group. */ /* Serialize each consumer group. */
raxStart(&ri,s->cgroups); raxStart(&ri,s->cgroups);
raxSeek(&ri,"^",NULL,0); raxSeek(&ri,"^",NULL,0);
@ -904,7 +906,8 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
streamCG *cg = ri.data; streamCG *cg = ri.data;
/* Save the group name. */ /* Save the group name. */
if ((n = rdbSaveRawString(rdb,ri.key,ri.key_len)) == -1) return -1; if ((n = rdbSaveRawString(rdb,ri.key,ri.key_len)) == -1)
return -1;
nwritten += n; nwritten += n;
/* Last ID. */ /* Last ID. */
@ -922,6 +925,7 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
nwritten += n; nwritten += n;
} }
raxStop(&ri); raxStop(&ri);
}
} else if (o->type == OBJ_MODULE) { } else if (o->type == OBJ_MODULE) {
/* Save a module-specific value. */ /* Save a module-specific value. */
RedisModuleIO io; RedisModuleIO io;