Hi, I'm unsure exactly how to test this easily and provide a bug report, but we seem to be experiencing an issue with UNLINK when a BGSAVE is running.
Situation is, we have a bunch of keys that we clear down with UNLINK, one of those keys is a set. The next command after the UNLINK is to test for SISMEMBER of the set.
Our BGSAVE takes some time ~30s. If we call the commands when no BGSAVE is running then it works as expected, SISMEMBER returns false as the key doesn't exist any longer. If we call this when BGSAVE is running then it returns true.
If DEL is used instead of UNLINK then I believe it waits for the BGSAVE to be completed.
SADD myset "Hello"
-> BGSAVE starts
- UNLINK myset .... (and many other keys)
- SISMEMBER myset "Hello" 1
-> BGSAVE finishes
Does this sound like expected behaviour? How could I set up a repl to reproduce the bug outside of my code, it seems like you need a big dataset in Redis to make BGSAVE take some time.
Thanks
Comment From: enjoy-binbin
are you sure? this seem a bad bug if it is real
unable to reproduce:
127.0.0.1:6379> debug populate 1000000
OK
127.0.0.1:6379> config set rdb-key-save-delay 10000000
OK
127.0.0.1:6379> SADD myset "Hello"
(integer) 1
127.0.0.1:6379> bgsave
Background saving started
127.0.0.1:6379> UNLINK myset
(integer) 1
127.0.0.1:6379> SISMEMBER myset "Hello"
(integer) 0
127.0.0.1:6379> save
(error) ERR Background save already in progress
Comment From: rad-pat
Interesting that you cannot reproduce yet the behaviour is happening regularly for us within our application.
The only think I know for sure is that after I call UNLINK and then call SISMEMBER, it is returning 1 when it should not and this only appears to be the case when the BGSAVE is running. Can you adjust your test to create more keys to unlink including the set, just in case volume in UNLINK is a factor?
I will try to pin down some more specific details if I can.
Comment From: enjoy-binbin
Can you adjust your test to create more keys to unlink including the set, just in case volume in UNLINK is a factor?
i don't think it will help. as far as i know the code, it doesn’t matter how many keys you type
please also state your Redis version and also check your application code.
Comment From: enjoy-binbin
i am closing it, if you have any other question, feel free to post it in here again.
Comment From: rad-pat
i am closing it, if you have any other question, feel free to post it in here again.
OK, thanks. We are trying upgrade to latest version, if there is still a problem then I will get some specific details and log an issue.