The simplest solution would be to increase your 'down-after-milliseconds' option in your Sentinel configurations, but that may increase the amount of time you have to wait for a failure to be detected.
As an alternative, you can fetch a subset of your keyspace at a time, and delete the keys in chunks. It is not atomic (if someone writes data while you are clearing your data, that data may or may not survive the cleaning)
Here is a simple Python function that will clean out 100 keys at a time (by default) from a provided db connection:
def clean(conn, count=100, match=None):
cursor = '0'
while cursor != 0:
cursor, keys = conn.scan(cursor, match=match, count=count)
if keys:
conn.delete(*keys)
That function should prevent the sentinel timeouts you've been experiencing, but as I mentioned before, if other writes occur, you may or may not have the newly written data after the clean() function completes.
- Josiah