Add more logging around message retention policies support (#6717)

So we can debug issues like #6683 more easily
This commit is contained in:
Brendan Abolivier 2020-01-17 20:51:44 +00:00 committed by GitHub
parent 5909751936
commit a17f64361c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

1
changelog.d/6717.misc Normal file
View File

@ -0,0 +1 @@
Add more logging around message retention policies support.

View File

@ -294,6 +294,14 @@ class ServerConfig(Config):
self.retention_default_min_lifetime = None self.retention_default_min_lifetime = None
self.retention_default_max_lifetime = None self.retention_default_max_lifetime = None
if self.retention_enabled:
logger.info(
"Message retention policies support enabled with the following default"
" policy: min_lifetime = %s ; max_lifetime = %s",
self.retention_default_min_lifetime,
self.retention_default_max_lifetime,
)
self.retention_allowed_lifetime_min = retention_config.get( self.retention_allowed_lifetime_min = retention_config.get(
"allowed_lifetime_min" "allowed_lifetime_min"
) )

View File

@ -88,6 +88,8 @@ class PaginationHandler(object):
if hs.config.retention_enabled: if hs.config.retention_enabled:
# Run the purge jobs described in the configuration file. # Run the purge jobs described in the configuration file.
for job in hs.config.retention_purge_jobs: for job in hs.config.retention_purge_jobs:
logger.info("Setting up purge job with config: %s", job)
self.clock.looping_call( self.clock.looping_call(
run_as_background_process, run_as_background_process,
job["interval"], job["interval"],
@ -130,11 +132,22 @@ class PaginationHandler(object):
else: else:
include_null = False include_null = False
logger.info(
"[purge] Running purge job for %d < max_lifetime <= %d (include NULLs = %s)",
min_ms,
max_ms,
include_null,
)
rooms = yield self.store.get_rooms_for_retention_period_in_range( rooms = yield self.store.get_rooms_for_retention_period_in_range(
min_ms, max_ms, include_null min_ms, max_ms, include_null
) )
logger.debug("[purge] Rooms to purge: %s", rooms)
for room_id, retention_policy in iteritems(rooms): for room_id, retention_policy in iteritems(rooms):
logger.info("[purge] Attempting to purge messages in room %s", room_id)
if room_id in self._purges_in_progress_by_room: if room_id in self._purges_in_progress_by_room:
logger.warning( logger.warning(
"[purge] not purging room %s as there's an ongoing purge running" "[purge] not purging room %s as there's an ongoing purge running"