From a02d609b1ffdc313fc1e06a68228ad2cb45919ec Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sat, 11 Feb 2017 20:44:16 -0500 Subject: [PATCH 1/9] Fix synapse_port_db failure (fixes #1902) See https://matrix.to/#/!cURbafjkfsMDVwdRDQ:matrix.org/$148686272020hCgRD:potatofrom.space Signed-off-by: Kevin Liu --- scripts/synapse_port_db | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/synapse_port_db b/scripts/synapse_port_db index 2cb2eab68..4bd110c32 100755 --- a/scripts/synapse_port_db +++ b/scripts/synapse_port_db @@ -40,6 +40,7 @@ BOOLEAN_COLUMNS = { "presence_list": ["accepted"], "presence_stream": ["currently_active"], "public_room_list_stream": ["visibility"], + "device_list_outbound_pokes": ["sent"], } From 70a00eacf9ebdca70966fa8c343d55d6e9232973 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sat, 11 Feb 2017 20:49:31 -0500 Subject: [PATCH 2/9] Fix typo This is what I get for not proofreading --- scripts/synapse_port_db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/synapse_port_db b/scripts/synapse_port_db index 4bd110c32..ea367a128 100755 --- a/scripts/synapse_port_db +++ b/scripts/synapse_port_db @@ -40,7 +40,7 @@ BOOLEAN_COLUMNS = { "presence_list": ["accepted"], "presence_stream": ["currently_active"], "public_room_list_stream": ["visibility"], - "device_list_outbound_pokes": ["sent"], + "device_lists_outbound_pokes": ["sent"], } From 49f4bc470993136ee4f5af7c34bee5ddc22768bd Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 27 Feb 2017 18:33:41 +0000 Subject: [PATCH 3/9] Don't fetch current state in common case Currently we fetch the list of current state events whenever we send something in a room. This is overkill for the common case of persisting a simple chain of non-state events, so lets handle that case specially. --- synapse/storage/events.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index c88f689d3..a4ce71cb2 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -311,6 +311,23 @@ class EventsStore(SQLBaseStore): new_forward_extremeties[room_id] = new_latest_event_ids + len_1 = ( + len(latest_event_ids) == 1 + and len(new_latest_event_ids) == 1 + ) + if len_1: + all_single_prev_not_state = any( + len(event.prev_events) == 1 + and not event.is_state() + for event, ctx in ev_ctx_rm + if not event.internal_metadata.is_outlier() + and not ctx.rejected + ) + # Don't bother calculating state if they're just + # a long chain of single ancestor non-state events. + if all_single_prev_not_state: + continue + state = yield self._calculate_state_delta( room_id, ev_ctx_rm, new_latest_event_ids ) From c0d6045776909a83181a4a925198c58e625ea4a2 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 27 Feb 2017 18:45:24 +0000 Subject: [PATCH 4/9] It should be all --- synapse/storage/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index a4ce71cb2..08807deba 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -316,7 +316,7 @@ class EventsStore(SQLBaseStore): and len(new_latest_event_ids) == 1 ) if len_1: - all_single_prev_not_state = any( + all_single_prev_not_state = all( len(event.prev_events) == 1 and not event.is_state() for event, ctx in ev_ctx_rm From a41dce8f8ae8bfb957a5830783e00437b4636c10 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 27 Feb 2017 18:54:43 +0000 Subject: [PATCH 5/9] Remove needless check --- synapse/storage/events.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/synapse/storage/events.py b/synapse/storage/events.py index 08807deba..db01eb6d1 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -320,8 +320,6 @@ class EventsStore(SQLBaseStore): len(event.prev_events) == 1 and not event.is_state() for event, ctx in ev_ctx_rm - if not event.internal_metadata.is_outlier() - and not ctx.rejected ) # Don't bother calculating state if they're just # a long chain of single ancestor non-state events. From 64a2cef9bb2b0cf62b2a72f63c25c4781c8354e2 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 27 Feb 2017 19:15:36 +0000 Subject: [PATCH 6/9] Pop rather than del from dict --- synapse/handlers/federation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 996bfd0e2..06d453017 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -1096,7 +1096,7 @@ class FederationHandler(BaseHandler): if prev_id != event.event_id: results[(event.type, event.state_key)] = prev_id else: - del results[(event.type, event.state_key)] + results.pop((event.type, event.state_key)) defer.returnValue(results.values()) else: From 9037787f0b655067eb28ae689745e60e7472e7b9 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 28 Feb 2017 00:29:54 +0000 Subject: [PATCH 7/9] merge in right archlinux package, thanks to @saram-kon from https://github.com/matrix-org/synapse/pull/1956 --- contrib/systemd/synapse.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/systemd/synapse.service b/contrib/systemd/synapse.service index 967a4debf..92d94b9d5 100644 --- a/contrib/systemd/synapse.service +++ b/contrib/systemd/synapse.service @@ -1,5 +1,5 @@ # This assumes that Synapse has been installed as a system package -# (e.g. https://aur.archlinux.org/packages/matrix-synapse/ for ArchLinux) +# (e.g. https://www.archlinux.org/packages/community/any/matrix-synapse/ for ArchLinux) # rather than in a user home directory or similar under virtualenv. [Unit] From 848cf95ea088ea6bff209d8fdb7bdb809d7aa8fa Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 28 Feb 2017 10:01:19 +0000 Subject: [PATCH 8/9] Pop with default value to stop throwing --- synapse/handlers/federation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 06d453017..ed0fa51e7 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -1096,7 +1096,7 @@ class FederationHandler(BaseHandler): if prev_id != event.event_id: results[(event.type, event.state_key)] = prev_id else: - results.pop((event.type, event.state_key)) + results.pop((event.type, event.state_key), None) defer.returnValue(results.values()) else: From 8a12b6f1eb16465bb2be816d3f92f07b844564d3 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 28 Feb 2017 10:15:50 +0000 Subject: [PATCH 9/9] Fix up txn name --- synapse/storage/devices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py index d22db0a0b..7b5903bf8 100644 --- a/synapse/storage/devices.py +++ b/synapse/storage/devices.py @@ -517,7 +517,7 @@ class DeviceStore(SQLBaseStore): WHERE stream_id > ? """ return self._execute( - "get_users_and_hosts_device_list", None, + "get_all_device_list_changes_for_remotes", None, sql, from_key, )