diff --git a/changelog.d/17816.bugfix b/changelog.d/17816.bugfix new file mode 100644 index 00000000000..5dd276709b0 --- /dev/null +++ b/changelog.d/17816.bugfix @@ -0,0 +1 @@ +Avoid lost data on some database query retries. diff --git a/synapse/storage/databases/main/media_repository.py b/synapse/storage/databases/main/media_repository.py index 7617fd3ad49..7a96e254321 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