From 4c1dab8c75099a60cf65c87a8a64db5f4caeffec Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 8 Oct 2024 14:09:11 -0500 Subject: [PATCH 1/2] Remove `Generator` in `update_cached_last_access_time` for both local and remote access times in two media repository tables --- synapse/storage/databases/main/media_repository.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/storage/databases/main/media_repository.py b/synapse/storage/databases/main/media_repository.py index 7617fd3ad4..7a96e25432 100644 --- a/synapse/storage/databases/main/media_repository.py +++ b/synapse/storage/databases/main/media_repository.py @@ -729,10 +729,10 @@ 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 = ( @@ -740,7 +740,7 @@ def update_cache_txn(txn: LoggingTransaction) -> None: " 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 From 023ebbccb0e24d2c8a7d3177971b4c11c42d1e53 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Thu, 10 Oct 2024 13:10:34 -0500 Subject: [PATCH 2/2] changelog --- changelog.d/17816.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17816.bugfix diff --git a/changelog.d/17816.bugfix b/changelog.d/17816.bugfix new file mode 100644 index 0000000000..5dd276709b --- /dev/null +++ b/changelog.d/17816.bugfix @@ -0,0 +1 @@ +Avoid lost data on some database query retries.