Describe the bug
When the client pause write is set and all the keys in the server are expired keys, executing the randomkey command will lead to an infinite loop.
To reproduce
- First, write a key with an expiration time. For example:
- Second, execute the client pause command. For example:
- Third, wait for the key to expire, and then execute the randomkey command while the client pause is still in effect.
Expected behavior
It is expected that the redis-server will return an expired key. However, in reality, there is no response at all, and the CPU utilization of the process reaches 100%.
Additional information
This bug will directly render redis-server unavailable.