mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
Call reset_queries in our queue workers.
This fixes a small memory leak in our queue workers, where we don't reset the accumulated times contained in our query logging data. Longer-term, we may want to make something mergable for mainline where we only store on the connection object the totals; that would be a fixed amount of emmory per connection and thus not have this problem. (imported from commit 914fa13acfb576f73c5f35e0f64c2f4d8a56b111)
This commit is contained in:
@@ -17,6 +17,7 @@ from zerver.lib.digest import handle_digest_email
|
|||||||
from zerver.decorator import JsonableError
|
from zerver.decorator import JsonableError
|
||||||
from zerver.lib.socket import req_redis_key
|
from zerver.lib.socket import req_redis_key
|
||||||
from confirmation.models import Confirmation
|
from confirmation.models import Confirmation
|
||||||
|
from django.db import reset_queries
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -65,6 +66,7 @@ class QueueProcessingWorker(object):
|
|||||||
with lockfile(lock_fn):
|
with lockfile(lock_fn):
|
||||||
with open(fn, 'a') as f:
|
with open(fn, 'a') as f:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
reset_queries()
|
||||||
|
|
||||||
def _log_problem(self):
|
def _log_problem(self):
|
||||||
logging.exception("Problem handling data on queue %s" % (self.queue_name,))
|
logging.exception("Problem handling data on queue %s" % (self.queue_name,))
|
||||||
@@ -193,6 +195,7 @@ class MissedMessageWorker(QueueProcessingWorker):
|
|||||||
for user_profile_id, events in by_recipient.items():
|
for user_profile_id, events in by_recipient.items():
|
||||||
handle_missedmessage_emails(user_profile_id, events)
|
handle_missedmessage_emails(user_profile_id, events)
|
||||||
|
|
||||||
|
reset_queries()
|
||||||
# Aggregate all messages received every 2 minutes to let someone finish sending a batch
|
# Aggregate all messages received every 2 minutes to let someone finish sending a batch
|
||||||
# of messages
|
# of messages
|
||||||
time.sleep(2 * 60)
|
time.sleep(2 * 60)
|
||||||
@@ -259,6 +262,8 @@ class SlowQueryWorker(QueueProcessingWorker):
|
|||||||
|
|
||||||
internal_send_message(settings.ERROR_BOT, "stream", "logs", topic, content)
|
internal_send_message(settings.ERROR_BOT, "stream", "logs", topic, content)
|
||||||
|
|
||||||
|
reset_queries()
|
||||||
|
|
||||||
@assign_queue("message_sender")
|
@assign_queue("message_sender")
|
||||||
class MessageSenderWorker(QueueProcessingWorker):
|
class MessageSenderWorker(QueueProcessingWorker):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user