Improve logging of backfill count

This commit is contained in:
Tulir Asokan
2022-02-28 12:36:43 +02:00
parent 2cf7fc7059
commit 98142f28cd
+9 -8
View File
@@ -2815,20 +2815,21 @@ class Portal(DBPortal, BasePortal):
return return
if limit < 0: if limit < 0:
limit = last_tgid - min_id limit = last_tgid - min_id
self.log.debug( limit_type = "unlimited"
f"Backfilling approximately {last_tgid - min_id} messages through {source.mxid}"
)
elif self.peer_type == "channel": elif self.peer_type == "channel":
min_id = max(last_tgid - limit, min_id) min_id = max(last_tgid - limit, min_id)
self.log.debug( # This is now just an approximate message count, not the actual limit.
f"Backfilling messages after ID {min_id} (last message: {last_tgid}) " limit = last_tgid - min_id
f"through {source.mxid}" limit_type = "channel"
)
else: else:
# This limit will be higher than the actual message count if there are any messages # This limit will be higher than the actual message count if there are any messages
# in other DMs or normal groups, but that's not too bad. # in other DMs or normal groups, but that's not too bad.
limit = min(last_tgid - min_id, limit) limit = min(last_tgid - min_id, limit)
self.log.debug(f"Backfilling up to {limit} messages through {source.mxid}") limit_type = "dm/minigroup"
self.log.debug(
f"Backfilling up to {limit} messages after ID {min_id} through {source.mxid} "
f"(last message: {last_tgid}, limit type: {limit_type})"
)
with self.backfill_lock: with self.backfill_lock:
await self._backfill(source, min_id, limit) await self._backfill(source, min_id, limit)