Skip to content

Commit

Permalink
Remove Generator in update_cached_last_access_time (#17816)
Browse files Browse the repository at this point in the history
Context: matrix-org/synapse#15439
(#15439)

Also see discussion in #17813
  • Loading branch information
realtyem authored Oct 31, 2024
1 parent 2e5fe3f commit 0c429fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/17816.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid lost data on some database query retries.
6 changes: 3 additions & 3 deletions synapse/storage/databases/main/media_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,18 +729,18 @@ def update_cache_txn(txn: LoggingTransaction) -> None:

txn.execute_batch(
sql,
(
[
(time_ms, media_origin, media_id)
for media_origin, media_id in remote_media
),
],
)

sql = (
"UPDATE local_media_repository SET last_access_ts = ?"
" WHERE media_id = ?"
)

txn.execute_batch(sql, ((time_ms, media_id) for media_id in local_media))
txn.execute_batch(sql, [(time_ms, media_id) for media_id in local_media])

await self.db_pool.runInteraction(
"update_cached_last_access_time", update_cache_txn
Expand Down

0 comments on commit 0c429fa

Please sign in to comment.