diff --git a/changelog.d/19765.misc b/changelog.d/19765.misc new file mode 100644 index 0000000000..7ac5375c7e --- /dev/null +++ b/changelog.d/19765.misc @@ -0,0 +1 @@ +Improve Synapse logging around when someone encounters `We can't get valid state history.` so you can correlate everything by `event_id`. diff --git a/synapse/handlers/federation_event.py b/synapse/handlers/federation_event.py index e314180e12..7cbc52d350 100644 --- a/synapse/handlers/federation_event.py +++ b/synapse/handlers/federation_event.py @@ -1166,9 +1166,10 @@ class FederationEventHandler: return await self._state_handler.compute_event_context(event) logger.info( - "Event %s is missing prev_events %s: calculating state for a " - "backwards extremity", + "_compute_event_context_with_maybe_missing_prevs(event_id=%s): Event in room %s is missing prev_events %s: " + "calculating state for a backwards extremity", event_id, + room_id, shortstr(missing_prevs), ) # Calculate the state after each of the previous events, and @@ -1186,16 +1187,21 @@ class FederationEventHandler: # Ask the remote server for the states we don't # know about - for p in missing_prevs: - logger.info("Requesting state after missing prev_event %s", p) + for missing_prev in missing_prevs: + logger.info( + "_compute_event_context_with_maybe_missing_prevs(event_id=%s): Requesting state from %s for missing prev_event %s", + event_id, + dest, + missing_prev, + ) - with nested_logging_context(p): + with nested_logging_context(missing_prev): # note that if any of the missing prevs share missing state or # auth events, the requests to fetch those events are deduped # by the get_pdu_cache in federation_client. remote_state_map = ( await self._get_state_ids_after_missing_prev_event( - dest, room_id, p + dest, room_id, missing_prev ) ) @@ -1225,7 +1231,11 @@ class FederationEventHandler: except Exception as e: logger.warning( - "Error attempting to resolve state at missing prev_events: %s", e + "_compute_event_context_with_maybe_missing_prevs(event_id=%s): Error attempting to resolve state from " + "%s for missing prev_events: %s", + event_id, + dest, + e, ) raise FederationError( "ERROR",