From 9888b8b9eff38c519732b161ef634ecb5c10c831 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 6 Apr 2022 12:05:17 +0100 Subject: [PATCH] Fix `synapse_event_persisted_position` metric Fixes a bug introduced in #11417 where we would only included backfilled events in `synapse_event_persisted_position` --- changelog.d/12390.bugfix | 1 + synapse/storage/databases/main/events.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelog.d/12390.bugfix diff --git a/changelog.d/12390.bugfix b/changelog.d/12390.bugfix new file mode 100644 index 000000000000..159c6b3c0fe8 --- /dev/null +++ b/changelog.d/12390.bugfix @@ -0,0 +1 @@ +Fix a bug introduced in Synapse 1.49.0 which caused the `synapse_event_persisted_position` metric to have invalid values. diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py index d253243125fb..ad0df2c6ea62 100644 --- a/synapse/storage/databases/main/events.py +++ b/synapse/storage/databases/main/events.py @@ -197,9 +197,9 @@ async def _persist_events_and_state_updates( ) persist_event_counter.inc(len(events_and_contexts)) - if stream < 0: - # backfilled events have negative stream orderings, so we don't - # want to set the event_persisted_position to that. + if not use_negative_stream_ordering: + # we don't want to set the event_persisted_position to a negative + # stream_ordering. synapse.metrics.event_persisted_position.set( events_and_contexts[-1][0].internal_metadata.stream_ordering )