4

Our keys are lost in some time and we cannot find the problem.

We are using AOF and RDB at the sametime with configs below:

RDB:

save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb

AOF:

appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes

As you can see there is no fancy... all are redis defaults.

I have tried to create keys and reboot the server. At this circumstances the keys still. I couldn't determine when keys are lost or why? The log files are not helpful cause I don't know what to query in logs or when.

All I know is my keys are lost at a time interval about one month.

How can I debug this kind of problem in redis?

  • Do you set a TTL for your keys? Is your server configured with an eviction policy? – Itamar Haber Jul 3 '17 at 18:19
  • @ItamarHaber nope! – Lupus Jul 4 '17 at 6:41
  • Then it sounds like there's a rogue user/code that's deleting your keys. – Itamar Haber Jul 4 '17 at 7:48
  • @ItamarHaber Is there a default eviction policy in redis confs. that causes a flush in db. – Lupus Jul 4 '17 at 9:11
  • 1
    Assuming that you meant 127.0.0.1, that would mean that only local connections are allowed... So, assuming no one broke into the server itself only to delete some keys that should be ok. You can try using MONITOR (note that it does impact performance) or keyspace notifications to trace and track rogue code that deletes the keys. In any case, Redis does not delete keys out of its own volition. – Itamar Haber Jul 4 '17 at 21:25
3

Preface: keys in Redis do not get deleted, unless explicitly requested or when the server is configured with an eviction policy (and RAM is pressured).

Regrettably, the most common cause for missing keys is security, or rather the lack of it. Script kids, leet haxors and regular bad guys take advantage of unprotected servers and cause all kinds of havoc. The first thing you need to do is ensure that the server is protected properly (i.e. is configured with a password and is not exposed to the world). For more details refer to https://redis.io/topics/security

After ruling out attacks and eviction policy configuration, the only remaining explanation is a rogue piece of code. From the server's side, you can try tracking this behavior using either the MONITOR command or by configuring keyspace events and subscribing to the relevant messages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.