summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <olivier@librepush.net>2019-08-30 11:21:40 +0100
committerOlivier Wilkinson (reivilibre) <olivier@librepush.net>2019-08-30 11:21:40 +0100
commit6c582d7ccbb52a6ec1e53611de536c6893576610 (patch)
tree0369f4fbf1c7b60a4c17c6ad1c1978d603caa14e /synapse/handlers
parentMerge branch 'rei/rss_target' into rei/rss_inc6 (diff)
parentMerge branch 'develop' into rei/rss_target (diff)
downloadsynapse-6c582d7ccbb52a6ec1e53611de536c6893576610.tar.xz
Merge branch 'rei/rss_target' into rei/rss_inc6
Diffstat (limited to '')
-rw-r--r--synapse/handlers/stats.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/synapse/handlers/stats.py b/synapse/handlers/stats.py
index 7536e1a54c..f44adfc07b 100644
--- a/synapse/handlers/stats.py
+++ b/synapse/handlers/stats.py
@@ -91,25 +91,31 @@ class StatsHandler(StateDeltasHandler):
             return None
 
         # Loop round handling deltas until we're up to date
-        with Measure(self.clock, "stats_delta"):
-            while True:
+
+        while True:
+            with Measure(self.clock, "stats_delta"):
                 deltas = yield self.store.get_current_state_deltas(
                     self.pos["state_delta_stream_id"]
                 )
-                if not deltas:
-                    break
 
                 logger.debug("Handling %d state deltas", len(deltas))
                 yield self._handle_deltas(deltas)
 
                 self.pos["state_delta_stream_id"] = deltas[-1]["stream_id"]
+                yield self.store.update_stats_positions(self.pos)
 
                 event_processing_positions.labels("stats").set(
                     self.pos["state_delta_stream_id"]
                 )
 
-                if self.pos is not None:
-                    yield self.store.update_stats_positions(self.pos)
+            # Then count deltas for total_events and total_event_bytes.
+            with Measure(self.clock, "stats_total_events_and_bytes"):
+                self.pos, had_counts = yield self.store.incremental_update_room_total_events_and_bytes(
+                    self.pos
+                )
+
+            if not deltas and not had_counts:
+                break
 
     @defer.inlineCallbacks
     def _handle_deltas(self, deltas):