summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-06-06 13:54:46 +0100
committerGitHub <noreply@github.com>2019-06-06 13:54:46 +0100
commit89d3d7b2c04e144647932845a847f57067b7c95c (patch)
treea999b35b62c5581725278cb9f1ef6c9af59234bd
parentMerge pull request #5089 from dnaf/m-heroes-empty-room-name (diff)
parentBetter words (diff)
downloadsynapse-89d3d7b2c04e144647932845a847f57067b7c95c.tar.xz
Merge pull request #5221 from matrix-org/erikj/fix_worker_sytest
Fix get_max_topological_token to never return None
Diffstat (limited to '')
-rw-r--r--changelog.d/5221.bugfix1
-rw-r--r--synapse/storage/stream.py12
2 files changed, 12 insertions, 1 deletions
diff --git a/changelog.d/5221.bugfix b/changelog.d/5221.bugfix
new file mode 100644
index 0000000000..03aa363d15
--- /dev/null
+++ b/changelog.d/5221.bugfix
@@ -0,0 +1 @@
+Fix race when backfilling in rooms with worker mode.
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 529ad4ea79..6f7f65d96b 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -592,8 +592,18 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
         )
 
     def get_max_topological_token(self, room_id, stream_key):
+        """Get the max topological token in a room before the given stream
+        ordering.
+
+        Args:
+            room_id (str)
+            stream_key (int)
+
+        Returns:
+            Deferred[int]
+        """
         sql = (
-            "SELECT max(topological_ordering) FROM events"
+            "SELECT coalesce(max(topological_ordering), 0) FROM events"
             " WHERE room_id = ? AND stream_ordering < ?"
         )
         return self._execute(