summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-08-07 10:00:03 +0100
committerRichard van der Hoff <richard@matrix.org>2018-08-07 10:00:03 +0100
commitca9bc1f4feaaabce48595ee2e387529f5bd365e6 (patch)
tree2094a202f1949f3ff8ff9984049ac56ede23e9b4 /synapse/storage/events.py
parentReturn M_NOT_FOUND when a profile could not be found. (#3596) (diff)
downloadsynapse-ca9bc1f4feaaabce48595ee2e387529f5bd365e6.tar.xz
Fix occasional glitches in the synapse_event_persisted_position metric
Every so often this metric glitched to a negative number. I'm assuming it was
due to backfilled events.
Diffstat (limited to 'synapse/storage/events.py')
-rw-r--r--synapse/storage/events.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index e8e5a0fe44..ce32e8fefd 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -485,9 +485,14 @@ class EventsStore(EventFederationStore, EventsWorkerStore, BackgroundUpdateStore
                     new_forward_extremeties=new_forward_extremeties,
                 )
                 persist_event_counter.inc(len(chunk))
-                synapse.metrics.event_persisted_position.set(
-                    chunk[-1][0].internal_metadata.stream_ordering,
-                )
+
+                if not backfilled:
+                    # backfilled events have negative stream orderings, so we don't
+                    # want to set the event_persisted_position to that.
+                    synapse.metrics.event_persisted_position.set(
+                        chunk[-1][0].internal_metadata.stream_ordering,
+                    )
+
                 for event, context in chunk:
                     if context.app_service:
                         origin_type = "local"