mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 14:54:56 -04:00
Replace or_ignore
in simple_insert
with simple_upsert
(#10442)
Now that we have `simple_upsert` that should be used in preference to trying to insert and looking for an exception. The main benefit is that we ERROR message don't get written to postgres logs. We also have tidy up the return value on `simple_upsert`, rather than having a tri-state of inserted/not-inserted/unknown.
This commit is contained in:
parent
d8324b8238
commit
38b346a504
6 changed files with 44 additions and 99 deletions
|
@ -297,17 +297,13 @@ class MonthlyActiveUsersStore(MonthlyActiveUsersWorkerStore):
|
|||
Args:
|
||||
txn (cursor):
|
||||
user_id (str): user to add/update
|
||||
|
||||
Returns:
|
||||
bool: True if a new entry was created, False if an
|
||||
existing one was updated.
|
||||
"""
|
||||
|
||||
# Am consciously deciding to lock the table on the basis that is ought
|
||||
# never be a big table and alternative approaches (batching multiple
|
||||
# upserts into a single txn) introduced a lot of extra complexity.
|
||||
# See https://github.com/matrix-org/synapse/issues/3854 for more
|
||||
is_insert = self.db_pool.simple_upsert_txn(
|
||||
self.db_pool.simple_upsert_txn(
|
||||
txn,
|
||||
table="monthly_active_users",
|
||||
keyvalues={"user_id": user_id},
|
||||
|
@ -322,8 +318,6 @@ class MonthlyActiveUsersStore(MonthlyActiveUsersWorkerStore):
|
|||
txn, self.user_last_seen_monthly_active, (user_id,)
|
||||
)
|
||||
|
||||
return is_insert
|
||||
|
||||
async def populate_monthly_active_users(self, user_id):
|
||||
"""Checks on the state of monthly active user limits and optionally
|
||||
add the user to the monthly active tables
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue