summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-08-07 14:48:08 +0100
committerGitHub <noreply@github.com>2018-08-07 14:48:08 +0100
commite5d2c678442af6fb3dd5d08829e3eedc61b4950e (patch)
tree77f646593a31544cf50ee67765bacf4083452a5a
parentfix event lag graph (diff)
parentchangelog (diff)
downloadsynapse-e5d2c678442af6fb3dd5d08829e3eedc61b4950e.tar.xz
Merge pull request #3658 from matrix-org/rav/fix_event_persisted_position_metrics
Fix occasional glitches in the synapse_event_persisted_position metric
-rw-r--r--changelog.d/3658.bugfix1
-rw-r--r--synapse/storage/events.py11
2 files changed, 9 insertions, 3 deletions
diff --git a/changelog.d/3658.bugfix b/changelog.d/3658.bugfix
new file mode 100644
index 0000000000..556011a150
--- /dev/null
+++ b/changelog.d/3658.bugfix
@@ -0,0 +1 @@
+Fix occasional glitches in the synapse_event_persisted_position metric
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"