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

Commit

Permalink
Add extra debug logging to federation sender (#12614)
Browse files Browse the repository at this point in the history
... in order to debug some problems we've been having with certain events not
being sent when expected.
  • Loading branch information
richvdh authored May 3, 2022
1 parent c4514b9 commit d66d68f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/12614.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add extra debug logging to federation sender.
20 changes: 18 additions & 2 deletions synapse/federation/sender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,24 @@ async def _process_event_queue_loop(self) -> None:
last_token, self._last_poked_id, limit=100
)

logger.debug("Handling %s -> %s", last_token, next_token)
logger.debug(
"Handling %i -> %i: %i events to send (current id %i)",
last_token,
next_token,
len(events),
self._last_poked_id,
)

if not events and next_token >= self._last_poked_id:
logger.debug("All events processed")
break

async def handle_event(event: EventBase) -> None:
# Only send events for this server.
send_on_behalf_of = event.internal_metadata.get_send_on_behalf_of()
is_mine = self.is_mine_id(event.sender)
if not is_mine and send_on_behalf_of is None:
logger.debug("Not sending remote-origin event %s", event)
return

# We also want to not send out-of-band membership events.
Expand Down Expand Up @@ -389,12 +397,16 @@ async def handle_event(event: EventBase) -> None:
# above).
#
if event.internal_metadata.is_out_of_band_membership():
logger.debug("Not sending OOB membership event %s", event)
return

# Finally, there are some other events that we should not send out
# until someone asks for them. They are explicitly flagged as such
# with `proactively_send: False`.
if not event.internal_metadata.should_proactively_send():
logger.debug(
"Not sending event with proactively_send=false: %s", event
)
return

destinations: Optional[Set[str]] = None
Expand Down Expand Up @@ -458,7 +470,10 @@ async def handle_event(event: EventBase) -> None:
"federation_sender"
).observe((now - ts) / 1000)

async def handle_room_events(events: Iterable[EventBase]) -> None:
async def handle_room_events(events: List[EventBase]) -> None:
logger.debug(
"Handling %i events in room %s", len(events), events[0].room_id
)
with Measure(self.clock, "handle_room_events"):
for event in events:
await handle_event(event)
Expand All @@ -477,6 +492,7 @@ async def handle_room_events(events: Iterable[EventBase]) -> None:
)
)

logger.debug("Successfully handled up to %i", next_token)
await self.store.update_federation_out_pos("events", next_token)

if events:
Expand Down

0 comments on commit d66d68f

Please sign in to comment.