mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
Warn if TTL of redis key is -1
(imported from commit f44ccef6dee190f531537fc8f3af9354c737a17f)
This commit is contained in:
@@ -30,12 +30,16 @@ class Command(BaseCommand):
|
|||||||
user = None
|
user = None
|
||||||
max_calls = max_api_calls(user=user)
|
max_calls = max_api_calls(user=user)
|
||||||
|
|
||||||
|
age = client.ttl(key)
|
||||||
|
if age == '-1':
|
||||||
|
logging.error("Found key with age of -1, will never expire: %s" % (key,))
|
||||||
|
|
||||||
count = count_func()
|
count = count_func()
|
||||||
if count > max_calls:
|
if count > max_calls:
|
||||||
logging.error("Redis health check found key with more elements \
|
logging.error("Redis health check found key with more elements \
|
||||||
than max_api_calls! (trying to trim) %s %s" % (key, count))
|
than max_api_calls! (trying to trim) %s %s" % (key, count))
|
||||||
client.expire(key, max_api_window(user=user))
|
|
||||||
if self.trim:
|
if self.trim:
|
||||||
|
client.expire(key, max_api_window(user=user))
|
||||||
trim_func(key, max_calls)
|
trim_func(key, max_calls)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
|||||||
Reference in New Issue
Block a user