Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 57f6c49

Browse files
URL preview cache expiry logs: INFO -> DEBUG, text clarifications (#12720)
1 parent 17e1eb7 commit 57f6c49

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

changelog.d/12720.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Drop the logging level of status messages for the URL preview cache expiry job from INFO to DEBUG.

synapse/rest/media/v1/preview_url_resource.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ async def _expire_url_cache_data(self) -> None:
668668
logger.debug("Running url preview cache expiry")
669669

670670
if not (await self.store.db_pool.updates.has_completed_background_updates()):
671-
logger.info("Still running DB updates; skipping expiry")
671+
logger.debug("Still running DB updates; skipping url preview cache expiry")
672672
return
673673

674674
def try_remove_parent_dirs(dirs: Iterable[str]) -> None:
@@ -688,7 +688,9 @@ def try_remove_parent_dirs(dirs: Iterable[str]) -> None:
688688
# Failed, skip deleting the rest of the parent dirs
689689
if e.errno != errno.ENOTEMPTY:
690690
logger.warning(
691-
"Failed to remove media directory: %r: %s", dir, e
691+
"Failed to remove media directory while clearing url preview cache: %r: %s",
692+
dir,
693+
e,
692694
)
693695
break
694696

@@ -703,7 +705,11 @@ def try_remove_parent_dirs(dirs: Iterable[str]) -> None:
703705
except FileNotFoundError:
704706
pass # If the path doesn't exist, meh
705707
except OSError as e:
706-
logger.warning("Failed to remove media: %r: %s", media_id, e)
708+
logger.warning(
709+
"Failed to remove media while clearing url preview cache: %r: %s",
710+
media_id,
711+
e,
712+
)
707713
continue
708714

709715
removed_media.append(media_id)
@@ -714,9 +720,11 @@ def try_remove_parent_dirs(dirs: Iterable[str]) -> None:
714720
await self.store.delete_url_cache(removed_media)
715721

716722
if removed_media:
717-
logger.info("Deleted %d entries from url cache", len(removed_media))
723+
logger.debug(
724+
"Deleted %d entries from url preview cache", len(removed_media)
725+
)
718726
else:
719-
logger.debug("No entries removed from url cache")
727+
logger.debug("No entries removed from url preview cache")
720728

721729
# Now we delete old images associated with the url cache.
722730
# These may be cached for a bit on the client (i.e., they
@@ -733,7 +741,9 @@ def try_remove_parent_dirs(dirs: Iterable[str]) -> None:
733741
except FileNotFoundError:
734742
pass # If the path doesn't exist, meh
735743
except OSError as e:
736-
logger.warning("Failed to remove media: %r: %s", media_id, e)
744+
logger.warning(
745+
"Failed to remove media from url preview cache: %r: %s", media_id, e
746+
)
737747
continue
738748

739749
dirs = self.filepaths.url_cache_filepath_dirs_to_delete(media_id)
@@ -745,7 +755,9 @@ def try_remove_parent_dirs(dirs: Iterable[str]) -> None:
745755
except FileNotFoundError:
746756
pass # If the path doesn't exist, meh
747757
except OSError as e:
748-
logger.warning("Failed to remove media: %r: %s", media_id, e)
758+
logger.warning(
759+
"Failed to remove media from url preview cache: %r: %s", media_id, e
760+
)
749761
continue
750762

751763
removed_media.append(media_id)
@@ -758,9 +770,9 @@ def try_remove_parent_dirs(dirs: Iterable[str]) -> None:
758770
await self.store.delete_url_cache_media(removed_media)
759771

760772
if removed_media:
761-
logger.info("Deleted %d media from url cache", len(removed_media))
773+
logger.debug("Deleted %d media from url preview cache", len(removed_media))
762774
else:
763-
logger.debug("No media removed from url cache")
775+
logger.debug("No media removed from url preview cache")
764776

765777

766778
def _is_media(content_type: str) -> bool:

0 commit comments

Comments
 (0)