Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

fix race condiftion in calling initialise_reserved_users #4081

Merged
merged 7 commits into from
Oct 25, 2018

Conversation

neilisfragile
Copy link
Contributor

No description provided.

@neilisfragile neilisfragile requested a review from a team October 23, 2018 14:26
synapse/storage/monthly_active_users.py Outdated Show resolved Hide resolved
synapse/storage/monthly_active_users.py Show resolved Hide resolved
synapse/storage/monthly_active_users.py Outdated Show resolved Hide resolved
synapse/storage/monthly_active_users.py Outdated Show resolved Hide resolved
synapse/storage/monthly_active_users.py Outdated Show resolved Hide resolved
synapse/storage/monthly_active_users.py Outdated Show resolved Hide resolved
synapse/storage/monthly_active_users.py Show resolved Hide resolved
synapse/storage/monthly_active_users.py Show resolved Hide resolved
synapse/storage/monthly_active_users.py Outdated Show resolved Hide resolved
synapse/storage/registration.py Show resolved Hide resolved
changelog.d/4081.bugfix Outdated Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm other than the below.

user_id (str): user to add/update
"""
is_insert = yield self.runInteraction(
"upsert_monthly_active_user", self.upsert_monthly_active_user_txn,
user_id
)
# Considered pushing cache invalidation down into txn method, but
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this isn't terribly easy to read; and I think it's actually more important to put something in the _txn method. How about getting rid of this, and instead, putting the following in the docstring of the _txn method:

Note that, after calling this method, it will generally be necessary to invalidate the caches on user_last_seen_monthly_active and get_monthly_active_count. We can't do that here, because we are running in a database thread rather than the main thread, and we can't call txn.call_after because txn may not be a LoggingTransaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm

@richvdh richvdh assigned neilisfragile and unassigned richvdh Oct 25, 2018

def upsert_monthly_active_user_txn(self, txn, user_id):
"""Updates or inserts monthly active user member
Note that, after calling this method, it will generally be necessary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest an extra blank line here:

Suggested change
Note that, after calling this method, it will generally be necessary
Note that, after calling this method, it will generally be necessary

@neilisfragile neilisfragile merged commit 95ad128 into develop Oct 25, 2018
@neilisfragile neilisfragile deleted the neilj/fix_mau_init branch October 25, 2018 15:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants