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

Commit

Permalink
URL preview cache expiry logs: INFO -> DEBUG, text clarifications (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 authored May 12, 2022
1 parent 17e1eb7 commit 57f6c49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.d/12720.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop the logging level of status messages for the URL preview cache expiry job from INFO to DEBUG.
30 changes: 21 additions & 9 deletions synapse/rest/media/v1/preview_url_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ async def _expire_url_cache_data(self) -> None:
logger.debug("Running url preview cache expiry")

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

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

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

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

if removed_media:
logger.info("Deleted %d entries from url cache", len(removed_media))
logger.debug(
"Deleted %d entries from url preview cache", len(removed_media)
)
else:
logger.debug("No entries removed from url cache")
logger.debug("No entries removed from url preview cache")

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

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

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

if removed_media:
logger.info("Deleted %d media from url cache", len(removed_media))
logger.debug("Deleted %d media from url preview cache", len(removed_media))
else:
logger.debug("No media removed from url cache")
logger.debug("No media removed from url preview cache")


def _is_media(content_type: str) -> bool:
Expand Down

0 comments on commit 57f6c49

Please sign in to comment.