Repository: valkey-io/valkey
File: src/rdb.c (C)

Code before:
                /* continue to next field */
                continue;
            }

            /* Add pair to hash table */
            entry *entry = entryCreate(field, value, itemexpiry);
            sdsfree(field);
            if (!hashtableAdd((hashtable *)objectGetVal(o), entry)) {
                rdbReportCorruptRDB("Duplicate hash fields detected");
                entryFree(entry);
                decrRefCount(o);
                return NULL;
            }

            if (rdbtype == RDB_TYPE_HASH_2 && itemexpiry != EXPIRY_NONE) {
                hashTypeTrackEntry(o, entry);
            }
        }

        /* All pairs should be read by now */
        serverAssert(len == 0);

        /* Check if hash became empty after skipping all expired fields */
        if (hashTypeLength(o) == 0) {
            decrRefCount(o);
            goto emptykey;
        }
    } else if (rdbtype == RDB_TYPE_LIST_QUICKLIST || rdbtype == RDB_TYPE_LIST_QUICKLIST_2) {
        if ((len = rdbLoadLen(rdb, NULL)) == RDB_LENERR) return NULL;
        if (len == 0) goto emptykey;

        o = createQuicklistObject(server.list_max_listpack_size, server.list_compress_depth);
        uint64_t container = QUICKLIST_NODE_CONTAINER_PACKED;
        while (len--) {
            unsigned char *lp;
            size_t encoded_len;

            if (rdbtype == RDB_TYPE_LIST_QUICKLIST_2) {
                if ((container = rdbLoadLen(rdb, NULL)) == RDB_LENERR) {
                    decrRefCount(o);
                    return NULL;
                }

                if (container != QUICKLIST_NODE_CONTAINER_PACKED && container != QUICKLIST_NODE_CONTAINER_PLAIN) {
                    rdbReportCorruptRDB("Quicklist integrity check failed.");
                    decrRefCount(o);
                    return NULL;
                }
            }

            unsigned char *data = rdbGenericLoadStringObject(rdb, RDB_LOAD_PLAIN, &encoded_len);

Review comment (bug):
Probably not a good idea. It will just increment the existing empty-keys stat that might already be tracked by some as an indication for another bug. I suggest to return a new error (eg RDB_ERROR_ALL_ITEMES_EXPIRED) and issue no log there 

Code after:
            }

            /* Add pair to hash table */
            entry *entry = entryCreate(field, value, itemexpiry);
            sdsfree(field);
            if (!hashtableAdd((hashtable *)objectGetVal(o), entry)) {
                rdbReportCorruptRDB("Duplicate hash fields detected");
                entryFree(entry);
                decrRefCount(o);
                return NULL;
            }

            if (rdbtype == RDB_TYPE_HASH_2 && itemexpiry != EXPIRY_NONE) {
                hashTypeTrackEntry(o, entry);
            }
        }

        /* All pairs should be read by now */
        serverAssert(len == 0);

        /* Check if hash became empty after skipping all expired fields */
        if (hashTypeLength(o) == 0) {
            decrRefCount(o);
            if (error) *error = RDB_LOAD_ERR_ALL_ITEMS_EXPIRED;
            return NULL;
        }
    } else if (rdbtype == RDB_TYPE_LIST_QUICKLIST || rdbtype == RDB_TYPE_LIST_QUICKLIST_2) {
        if ((len = rdbLoadLen(rdb, NULL)) == RDB_LENERR) return NULL;
        if (len == 0) goto emptykey;

        o = createQuicklistObject(server.list_max_listpack_size, server.list_compress_depth);
        uint64_t container = QUICKLIST_NODE_CONTAINER_PACKED;
        while (len--) {
            unsigned char *lp;
            size_t encoded_len;

            if (rdbtype == RDB_TYPE_LIST_QUICKLIST_2) {
                if ((container = rdbLoadLen(rdb, NULL)) == RDB_LENERR) {
                    decrRefCount(o);
                    return NULL;
                }

                if (container != QUICKLIST_NODE_CONTAINER_PACKED && container != QUICKLIST_NODE_CONTAINER_PLAIN) {
                    rdbReportCorruptRDB("Quicklist integrity check failed.");
                    decrRefCount(o);
                    return NULL;
                }
            }

            unsigned char *data = rdbGenericLoadStringObject(rdb, RDB_LOAD_PLAIN, &encoded_len);
            if (data == NULL || (encoded_len == 0)) {