zulip/zerver
Steve Howell 89381a8072 cache: Eliminate get-stream-by-name cache.
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.
2023-07-11 13:45:40 -07:00
..
actions cache: Eliminate get-stream-by-name cache. 2023-07-11 13:45:40 -07:00
data_import slack: Handle the special case of permissions denied on team.info call. 2023-06-27 11:04:41 -07:00
integration_fixtures/nagios
lib cache: Eliminate get-stream-by-name cache. 2023-07-11 13:45:40 -07:00
management delete-user: Update management command help doc-string. 2023-06-23 11:24:13 -07:00
migrations models: Add modified_user_group. 2023-07-11 08:56:55 -07:00
openapi tests: Improve automated tests for submessages. 2023-07-06 16:35:46 -07:00
tests cache: Eliminate get-stream-by-name cache. 2023-07-11 13:45:40 -07:00
tornado mention: Replace 'wildcards' with 'stream_wildcards'. 2023-07-03 22:03:17 -07:00
transaction_tests test_classes: Do not necessary wrap test cases in a transaction. 2023-07-06 11:44:50 -07:00
views sentry: Reduce http timeout. 2023-07-10 13:46:16 -07:00
webhooks integrations: Separate issue milestoned events in GitHub Integration. 2023-07-11 08:58:31 -07:00
worker queue_processors: Avoid queue worker timeouts in tests. 2023-06-28 11:06:24 -07:00
__init__.py
apps.py requirements: Upgrade Python requirements. 2023-04-03 22:39:21 -07:00
context_processors.py emails: Add corporate_enabled to context for emails. 2023-05-01 10:32:43 -07:00
decorator.py codespell: Correct “requestor” to “requester”. 2023-06-20 16:17:55 -07:00
filters.py
forms.py accounts: Allow user to change email visibility during first login. 2023-05-16 13:52:56 -07:00
logging_handlers.py python: Use Python 3.8 typing.{Protocol,TypedDict}. 2022-04-27 12:57:49 -07:00
middleware.py middleware: Detect reverse proxy misconfigurations. 2023-07-02 16:20:21 -07:00
models.py cache: Eliminate get-stream-by-name cache. 2023-07-11 13:45:40 -07:00
signals.py requirements: Upgrade to Django 4.0. 2022-07-13 16:07:17 -07:00