From 69af9c289d9315a9d0b24785d9b960a7c8ade24b Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Thu, 20 Oct 2022 13:02:46 +0200 Subject: [PATCH 1/4] Fix presence bug introduced in 1.64 by #13313 Signed-off-by: Mathieu Velten --- synapse/storage/databases/main/roommember.py | 1 - 1 file changed, 1 deletion(-) diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py index 32e1e983a5da..93bbc46208bd 100644 --- a/synapse/storage/databases/main/roommember.py +++ b/synapse/storage/databases/main/roommember.py @@ -751,7 +751,6 @@ def do_users_share_a_room_txn( 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)) From 1d5894f65a384d503fb065c9c5b36fc24a4560ae Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Thu, 20 Oct 2022 13:12:47 +0200 Subject: [PATCH 2/4] Add changelog --- changelog.d/14243.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/14243.bugfix diff --git a/changelog.d/14243.bugfix b/changelog.d/14243.bugfix new file mode 100644 index 000000000000..a8beacbbc41a --- /dev/null +++ b/changelog.d/14243.bugfix @@ -0,0 +1 @@ +Fix a bug introduced in Synapse 1.64.0 regarding presence updates in sync. From 442bb01dfe85d1832378513cb8fcab2fd4529c79 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Thu, 20 Oct 2022 17:14:52 +0200 Subject: [PATCH 3/4] Add DISTINCT --- synapse/storage/databases/main/roommember.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py index 93bbc46208bd..ab708b0ba599 100644 --- a/synapse/storage/databases/main/roommember.py +++ b/synapse/storage/databases/main/roommember.py @@ -742,7 +742,7 @@ def do_users_share_a_room_txn( # 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 = ? From ae061a0b48f1577b90d126a8367f50cd19a4033c Mon Sep 17 00:00:00 2001 From: David Robertson Date: Thu, 27 Oct 2022 13:15:40 +0100 Subject: [PATCH 4/4] Apply suggestions from code review --- changelog.d/14243.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/14243.bugfix b/changelog.d/14243.bugfix index a8beacbbc41a..ac0b21c2c5f9 100644 --- a/changelog.d/14243.bugfix +++ b/changelog.d/14243.bugfix @@ -1 +1 @@ -Fix a bug introduced in Synapse 1.64.0 regarding presence updates in sync. +Fix a bug introduced in Synapse 1.64.0 where presence updates could be missing from `/sync` responses.