Skip to content

Improve We can't get valid state history. logging#19765

Merged
MadLittleMods merged 3 commits into
developfrom
madlittlemods/improve-_compute_event_context_with_maybe_missing_prevs-log-message
May 13, 2026
Merged

Improve We can't get valid state history. logging#19765
MadLittleMods merged 3 commits into
developfrom
madlittlemods/improve-_compute_event_context_with_maybe_missing_prevs-log-message

Conversation

@MadLittleMods
Copy link
Copy Markdown
Contributor

@MadLittleMods MadLittleMods commented May 8, 2026

Improve We can't get valid state history. logging. Add event_id so you can actually correlate everything together in the logs.

Spawning from @jakobrss asking about what to look for when someone encounters this error

Dev notes

These logs originate from matrix-org/synapse#3904 where they used to have the room_id and event_id included directly but then was updated in matrix-org/synapse#9596 to rely on the log context holding this info.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

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: "
Copy link
Copy Markdown
Contributor Author

@MadLittleMods MadLittleMods May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These log messages can be refactored to not use the _compute_event_context_with_maybe_missing_prevs prefix if there is a strong preference.

Being able to search for _compute_event_context_with_maybe_missing_prevs sounds nice to me.

event_id,
room_id,
shortstr(missing_prevs),
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example logs:

SYNAPSE_TEST_LOG_LEVEL=DEBUG poetry run trial tests.handlers.test_federation_event.FederationEventHandlerTests.test_process_pulled_event_records_failed_backfill_attempts

_trial_temp/test.log

2026-05-08 07:18:38-0500 [-] synapse.handlers.federation_event - 1168 - INFO - test - _compute_event_context_with_maybe_missing_prevs(event_id=$C9yIQdfmuUAMM7Iziu5xft5kkFCRXdjPsBleizH0MBU): Event in room !tZrGbzfBcdXoJtzfLn:test is missing prev_events ['$fake_prev_event']: calculating state for a backwards extremity
2026-05-08 07:18:38-0500 [-] synapse.handlers.federation_event - 1191 - INFO - test - _compute_event_context_with_maybe_missing_prevs(event_id=$C9yIQdfmuUAMM7Iziu5xft5kkFCRXdjPsBleizH0MBU): Requesting state from other.example.com for missing prev_event $fake_prev_event
2026-05-08 07:18:38-0500 [-] synapse.handlers.federation_event - 1233 - WARNING - test - _compute_event_context_with_maybe_missing_prevs(event_id=$C9yIQdfmuUAMM7Iziu5xft5kkFCRXdjPsBleizH0MBU): Error attempting to resolve state from other.example.com for missing prev_events: Unable to get missing prev_event $fake_prev_event

@MadLittleMods MadLittleMods marked this pull request as ready for review May 8, 2026 12:22
@MadLittleMods MadLittleMods requested a review from a team as a code owner May 8, 2026 12:22
Copy link
Copy Markdown
Member

@erikjohnston erikjohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like decent improvements

@MadLittleMods MadLittleMods merged commit ff0420a into develop May 13, 2026
46 checks passed
@MadLittleMods MadLittleMods deleted the madlittlemods/improve-_compute_event_context_with_maybe_missing_prevs-log-message branch May 13, 2026 17:31
@MadLittleMods
Copy link
Copy Markdown
Contributor Author

Thanks for the review @erikjohnston 🐩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants