From 92a1f5196e1518b9fd89827830203438e81da45b Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Fri, 17 Apr 2020 11:34:26 +0100 Subject: [PATCH 1/3] Reduce verbosity of URL cache cleanup. This task runs every 10s, so log at info only if media/urls removed, as low-volume homeservers will be very verbose for little cleanup otherwise. We already skip the "deleted X entries" line if it's zero length. --- synapse/rest/media/v1/preview_url_resource.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py index f68e18ea8af5..89af069ed4c4 100644 --- a/synapse/rest/media/v1/preview_url_resource.py +++ b/synapse/rest/media/v1/preview_url_resource.py @@ -402,7 +402,7 @@ async def _expire_url_cache_data(self): now = self.clock.time_msec() - logger.info("Running url preview cache expiry") + logger.debug("Running url preview cache expiry") if not (await self.store.db.updates.has_completed_background_updates()): logger.info("Still running DB updates; skipping expiry") @@ -435,6 +435,8 @@ async def _expire_url_cache_data(self): if removed_media: logger.info("Deleted %d entries from url cache", len(removed_media)) + else: + logger.debug("No entries removed from url cache") # Now we delete old images associated with the url cache. # These may be cached for a bit on the client (i.e., they @@ -481,8 +483,10 @@ async def _expire_url_cache_data(self): await self.store.delete_url_cache_media(removed_media) - logger.info("Deleted %d media from url cache", len(removed_media)) - + if removed_media: + logger.info("Deleted %d media from url cache", len(removed_media)) + else: + logger.debug("No media removed from url cache") def decode_and_calc_og(body, media_uri, request_encoding=None): from lxml import etree From 088dcc7ebcb15eea401167b7d833c4881b657943 Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Fri, 17 Apr 2020 11:43:45 +0100 Subject: [PATCH 2/3] Changelog.d entry --- changelog.d/7295.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7295.misc diff --git a/changelog.d/7295.misc b/changelog.d/7295.misc new file mode 100644 index 000000000000..239195e75c22 --- /dev/null +++ b/changelog.d/7295.misc @@ -0,0 +1 @@ +Reduce log verbosity of url cache cleanup tasks. From 4aa9957c1a770b6fb4f3e6bcf8f619ad08a686c9 Mon Sep 17 00:00:00 2001 From: Michael Kaye <1917473+michaelkaye@users.noreply.github.com> Date: Tue, 21 Apr 2020 13:14:57 +0100 Subject: [PATCH 3/3] Update synapse/rest/media/v1/preview_url_resource.py Co-Authored-By: Patrick Cloke --- synapse/rest/media/v1/preview_url_resource.py | 1 + 1 file changed, 1 insertion(+) diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py index 89af069ed4c4..f206605727a0 100644 --- a/synapse/rest/media/v1/preview_url_resource.py +++ b/synapse/rest/media/v1/preview_url_resource.py @@ -488,6 +488,7 @@ async def _expire_url_cache_data(self): else: logger.debug("No media removed from url cache") + def decode_and_calc_og(body, media_uri, request_encoding=None): from lxml import etree