diff --git a/synapse/storage/databases/main/media_repository.py b/synapse/storage/databases/main/media_repository.py index 480a249b684a..626e892a0fbc 100644 --- a/synapse/storage/databases/main/media_repository.py +++ b/synapse/storage/databases/main/media_repository.py @@ -483,10 +483,10 @@ async def count_pending_media(self, user_id: UserID) -> Tuple[int, int]: def get_pending_media_txn(txn: LoggingTransaction) -> Tuple[int, int]: sql = """ - SELECT COUNT(*), MIN(created_at) + SELECT COUNT(*), MIN(created_ts) FROM local_media_repository WHERE user_id = ? - AND created_at > ? + AND created_ts > ? AND media_length IS NULL """ txn.execute( @@ -501,7 +501,7 @@ def get_pending_media_txn(txn: LoggingTransaction) -> Tuple[int, int]: return 0, 0 return row[0], (row[1] + self.unused_expiration_time if row[1] else 0) - return await self.db_pool.runInteraction("get_url_cache", get_pending_media_txn) + return await self.db_pool.runInteraction("get_pending_media", get_pending_media_txn) async def get_url_cache(self, url: str, ts: int) -> Optional[UrlCache]: """Get the media_id and ts for a cached URL as of the given timestamp