mirror of https://github.com/zulip/zulip.git
89381a8072
We remove the cache functionality for the get_realm_stream function, and we also change it to return a thin Stream object (instead of calling select_related with no arguments). The main goal here is to remove code complexity, as we have been prone to at least one caching validation bug related to how Realm and UserGroup interact. That particular bug was more theoretical than practical in terms of its impact, to be clear. Even if we were to be perfectly disciplined about only caching thin stream objects and always making sure to delete cache entries when stream data changed, we would still be prone to ugly situations like having transactions get rolled back before we delete the cache entry. The do_deactivate_stream is a perfect example of where we have to consider the best time to unset the cache. If you unset it too early, then you are prone to races where somebody else churns the cache right before you update the database. If you set it too late, then you can have an invalid entry after a rollback or deadlock situation. If you just eliminate the cache as a moving part, that whole debate is moot. As the lack of test changes here indicates, we rarely fetch streams by name any more in critical sections of our code. The one place where we fetch by name is in loading the home page, but that is **only** when you specify a stream name. And, of course, that only causes about an extra millisecond of time. |
||
---|---|---|
.. | ||
actions | ||
data_import | ||
integration_fixtures/nagios | ||
lib | ||
management | ||
migrations | ||
openapi | ||
tests | ||
tornado | ||
transaction_tests | ||
views | ||
webhooks | ||
worker | ||
__init__.py | ||
apps.py | ||
context_processors.py | ||
decorator.py | ||
filters.py | ||
forms.py | ||
logging_handlers.py | ||
middleware.py | ||
models.py | ||
signals.py |