The problem/use-case that the feature addresses
A description of the problem that the feature will solve, or the use-case with which the feature will be used.
use-case see issue Check migrated data consistency
User want to check data consistency after migration. so we could provide a command RESTORECOMPARE
RESTORECOMPARE key ttl serialized-value [ABSTTL]
To implement this command. pseudocode like following
int restoreCompare(key, ttl, serialized-value) {
// for example handle map comparison
map source = redis.get(key)
// deserialize dump value and store to temporary structure
map temp = deserialize(serialized-value)
// comparison process
if (source == nil) {
return 0
}
if (source equals temp) {
return 1
} else {
return 0
}
// if type is module.
// first compare module-name and module-version
// after above compare serialized-value directly.
}
After implement above command. redis-cli can add a diff option too.
redis-cli --diff dump.rdb -h 127.0.0.1 -p 6379
step1: convert dump.rdb to redis dump format.
step2: use RESTORECOMPARE to do diff process.
see also Fast and Efficient Parallelized Comparison of Redis Databases
Comment From: yangbodong22011
@leonchen83 Is there a new solution to your problem? For example, by dump key and comparing it locally.
Comment From: leonchen83
different rdb version has different RDB_TYPE
for example:
map may stored by following type
RDB_TYPE_HASH = 4;
RDB_TYPE_HASH_ZIPMAP = 9;
RDB_TYPE_HASH_ZIPLIST = 13;
RDB_TYPE_HASH_LISTPACK = 16;
so we need to compare every field in map type, compare dump directly can't solve problem
Comment From: yangbodong22011
different rdb version has different RDB_TYPE for example:
mapmay stored by following type
RDB_TYPE_HASH = 4; RDB_TYPE_HASH_ZIPMAP = 9; RDB_TYPE_HASH_ZIPLIST = 13; RDB_TYPE_HASH_LISTPACK = 16;so we need to compare every
fieldinmaptype, so comparedumpcan't solve problem
oh, i see, but it seems RESTORECOMPARE command is less necessary than comparing field/values by the client itself.
Comment From: leonchen83
yes, above can compare in client side, but server side provide this command can simplify compare process. RedisFullCheck and redis-rdb-cli can benefit from this command
Comment From: itamarhaber
@leonchen83 I didn't know/forgot about RedisFullCheck & RedisShake - cool :)