summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathieu Velten <mathieuv@matrix.org>2022-10-27 14:16:00 +0200
committerGitHub <noreply@github.com>2022-10-27 13:16:00 +0100
commit4dc05f30193935224103e8772b1bbc15293e5cb6 (patch)
tree86a95ca851b0748e4055c5ccd2d5f90685b5ac7e
parentReject history insertion during partial joins (#14291) (diff)
downloadsynapse-4dc05f30193935224103e8772b1bbc15293e5cb6.tar.xz
Fix presence bug introduced in 1.64 by #13313 (#14243)
* Fix presence bug introduced in 1.64 by #13313

Signed-off-by: Mathieu Velten <mathieuv@matrix.org>

* Add changelog

* Add DISTINCT

* Apply suggestions from code review

Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
-rw-r--r--changelog.d/14243.bugfix1
-rw-r--r--synapse/storage/databases/main/roommember.py3
2 files changed, 2 insertions, 2 deletions
diff --git a/changelog.d/14243.bugfix b/changelog.d/14243.bugfix
new file mode 100644
index 0000000000..ac0b21c2c5
--- /dev/null
+++ b/changelog.d/14243.bugfix
@@ -0,0 +1 @@
+Fix a bug introduced in Synapse 1.64.0 where presence updates could be missing from `/sync` responses.
diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py
index 32e1e983a5..ab708b0ba5 100644
--- a/synapse/storage/databases/main/roommember.py
+++ b/synapse/storage/databases/main/roommember.py
@@ -742,7 +742,7 @@ class RoomMemberWorkerStore(EventsWorkerStore):
             # user and the set of other users, and then checking if there is any
             # overlap.
             sql = f"""
-                SELECT b.state_key
+                SELECT DISTINCT b.state_key
                 FROM (
                     SELECT room_id FROM current_state_events
                     WHERE type = 'm.room.member' AND membership = 'join' AND state_key = ?
@@ -751,7 +751,6 @@ class RoomMemberWorkerStore(EventsWorkerStore):
                     SELECT room_id, state_key FROM current_state_events
                     WHERE type = 'm.room.member' AND membership = 'join' AND {clause}
                 ) AS b using (room_id)
-                LIMIT 1
             """
 
             txn.execute(sql, (user_id, *args))