Skip to content

Commit ff0420a

Browse files
Improve We can't get valid state history. logging (#19765)
Add `event_id` so you can actually correlate everything together in the logs.
1 parent 1409dbc commit ff0420a

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

changelog.d/19765.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve Synapse logging around when someone encounters `We can't get valid state history.` so you can correlate everything by `event_id`.

synapse/handlers/federation_event.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,10 @@ async def _compute_event_context_with_maybe_missing_prevs(
11661166
return await self._state_handler.compute_event_context(event)
11671167

11681168
logger.info(
1169-
"Event %s is missing prev_events %s: calculating state for a "
1170-
"backwards extremity",
1169+
"_compute_event_context_with_maybe_missing_prevs(event_id=%s): Event in room %s is missing prev_events %s: "
1170+
"calculating state for a backwards extremity",
11711171
event_id,
1172+
room_id,
11721173
shortstr(missing_prevs),
11731174
)
11741175
# Calculate the state after each of the previous events, and
@@ -1186,16 +1187,21 @@ async def _compute_event_context_with_maybe_missing_prevs(
11861187

11871188
# Ask the remote server for the states we don't
11881189
# know about
1189-
for p in missing_prevs:
1190-
logger.info("Requesting state after missing prev_event %s", p)
1190+
for missing_prev in missing_prevs:
1191+
logger.info(
1192+
"_compute_event_context_with_maybe_missing_prevs(event_id=%s): Requesting state from %s for missing prev_event %s",
1193+
event_id,
1194+
dest,
1195+
missing_prev,
1196+
)
11911197

1192-
with nested_logging_context(p):
1198+
with nested_logging_context(missing_prev):
11931199
# note that if any of the missing prevs share missing state or
11941200
# auth events, the requests to fetch those events are deduped
11951201
# by the get_pdu_cache in federation_client.
11961202
remote_state_map = (
11971203
await self._get_state_ids_after_missing_prev_event(
1198-
dest, room_id, p
1204+
dest, room_id, missing_prev
11991205
)
12001206
)
12011207

@@ -1225,7 +1231,11 @@ async def _compute_event_context_with_maybe_missing_prevs(
12251231

12261232
except Exception as e:
12271233
logger.warning(
1228-
"Error attempting to resolve state at missing prev_events: %s", e
1234+
"_compute_event_context_with_maybe_missing_prevs(event_id=%s): Error attempting to resolve state from "
1235+
"%s for missing prev_events: %s",
1236+
event_id,
1237+
dest,
1238+
e,
12291239
)
12301240
raise FederationError(
12311241
"ERROR",

0 commit comments

Comments
 (0)