#!/bin/sh
service redis-server restart
sleep 5
# Perform a synchronous save to ensure .rdb file exist
redis-cli SAVE
redis-check-rdb /var/lib/redis/dump.rdb
Results in:
OK
[offset 0] Checking RDB file /var/lib/redis/dump.rdb
[offset 26] AUX FIELD redis-ver = '6.0.0'
[offset 40] AUX FIELD redis-bits = '64'
[offset 52] AUX FIELD ctime = '1588503640'
[offset 67] AUX FIELD used-mem = '871136'
[offset 83] AUX FIELD aof-preamble = '0'
--- RDB ERROR DETECTED ---
[offset 92] RDB CRC error
[additional info] While doing: check-sum
[additional info] Reading type 0 (string)
[info] 0 keys read
[info] 0 expires
[info] 0 already expired
This is with 6.0.0.
Comment From: oranagra
@antirez @JohnSully either move the call to crc64_init to before redis_check_rdb_main, or add one explicitly inside redis-check-rdb.c and redis-check-aof.c
Comment From: JohnSully
@madolson FYI
Comment From: madolson
I'd be inclined to just have a check to see if crc64 is initialized or not when doing crc64, I think the explicit init is till valid with the main Redis.
Comment From: JohnSully
In my prototype I did it right at the beginning of main() so there was no chance for issues.
Comment From: antirez
@madolson I agree, fixed in this way in 1063f1d83.
Comment From: antirez
Btw also initializing it in main() could be a good idea indeed, only problem I see with this is that if we have a crash in CRC initialization, or abort there, Redis will not be setup to log and so forth.
Comment From: oranagra
for the record, two things bother me in this solution: 1. the initialization for redis-server is different than the initialization for redis-check-rdb, this could backfire some day (since one flow is tested less than the other). 2. if this code will some day be used with multi-threading (without an explicit init), it could cause a mess.
Comment From: antirez
@oranagra well the initialization is the same code path, it's just explicit in Redis to avoid the delay, and if this code will be used in threads, very likely it will be in the Redis server where it is explicitly initialized. But even if those are maybe not big problems, I see what you mean. I also think that it will be confusing to see why there is explicit initialization in one side and implicit. And then also why the conditional check in a code that is supposed to be fast? Yep it's just a comparison but... Let's move to main() initialization?
Comment From: antirez
I changed it initializing in main().