summary refs log tree commit diff
path: root/synapse/app
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-11-03 00:19:23 +1100
committerGitHub <noreply@github.com>2018-11-03 00:19:23 +1100
commitcb7a6b2379e0e0a4ba8043da98e376b45d05b977 (patch)
treea1eb48d453fc0b444216d2ebf0ea05af4f4244d4 /synapse/app
parentMerge pull request #4132 from matrix-org/rav/fix_device_list_locking (diff)
downloadsynapse-cb7a6b2379e0e0a4ba8043da98e376b45d05b977.tar.xz
Fix typing being reset causing infinite syncs (#4127)
Diffstat (limited to 'synapse/app')
-rw-r--r--synapse/app/synchrotron.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/app/synchrotron.py b/synapse/app/synchrotron.py
index 3926c7f263..0354e82bf8 100644
--- a/synapse/app/synchrotron.py
+++ b/synapse/app/synchrotron.py
@@ -226,7 +226,15 @@ class SynchrotronPresence(object):
 class SynchrotronTyping(object):
     def __init__(self, hs):
         self._latest_room_serial = 0
+        self._reset()
+
+    def _reset(self):
+        """
+        Reset the typing handler's data caches.
+        """
+        # map room IDs to serial numbers
         self._room_serials = {}
+        # map room IDs to sets of users currently typing
         self._room_typing = {}
 
     def stream_positions(self):
@@ -236,6 +244,12 @@ class SynchrotronTyping(object):
         return {"typing": self._latest_room_serial}
 
     def process_replication_rows(self, token, rows):
+        if self._latest_room_serial > token:
+            # The master has gone backwards. To prevent inconsistent data, just
+            # clear everything.
+            self._reset()
+
+        # Set the latest serial token to whatever the server gave us.
         self._latest_room_serial = token
 
         for row in rows: