cache: Fix the select_related() query name for sending_client.

Previously we were calling select_related() on Message.client, which
doesn't exist.  It seems kinda poor that this doesn't raise an
exception.

I believe this issue was causing us to do very large numbers of
database queries during get_updates calls during server restarts.

(imported from commit b79bd698820fbd9dd82bd61fc175c32cd5ce6d05)
This commit is contained in:
Tim Abbott 2013-03-15 14:11:58 -04:00
parent e080be82fb
commit d88591c19c
1 changed files with 2 additions and 2 deletions

View File

@ -13,12 +13,12 @@ def cache_save_message(message):
@cache_with_key(message_cache_key) @cache_with_key(message_cache_key)
def cache_get_message(message_id): def cache_get_message(message_id):
return Message.objects.select_related("client", "sender").get(id=message_id) return Message.objects.select_related("sending_client", "sender").get(id=message_id)
# Called on Tornado startup to ensure our message cache isn't empty # Called on Tornado startup to ensure our message cache isn't empty
def populate_message_cache(): def populate_message_cache():
items_for_memcached = {} items_for_memcached = {}
for m in Message.objects.select_related("sender", "client").all().order_by( for m in Message.objects.select_related("sending_client", "sender").all().order_by(
"-id")[0:MESSAGE_CACHE_SIZE]: "-id")[0:MESSAGE_CACHE_SIZE]:
items_for_memcached[message_cache_key(m.id)] = (m,) items_for_memcached[message_cache_key(m.id)] = (m,)