From e2cce15af16cd85d5379e8d961680028bfc9e754 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 5 Dec 2019 15:44:02 +0000 Subject: [PATCH 1/7] Remove #6369 changelog --- changelog.d/6369.doc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 changelog.d/6369.doc diff --git a/changelog.d/6369.doc b/changelog.d/6369.doc deleted file mode 100644 index 6db351d7db..0000000000 --- a/changelog.d/6369.doc +++ /dev/null @@ -1 +0,0 @@ -Update documentation and variables in user contributed systemd reference file. From 58fdcbdfe7f064f336f514b921a556c116c757cb Mon Sep 17 00:00:00 2001 From: Mark Nowiasz <36151963+mnowiasz@users.noreply.github.com> Date: Wed, 11 Dec 2019 17:23:38 +0100 Subject: [PATCH 2/7] Update workers.md to make media_repository work (again) (#6519) --- docs/workers.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/workers.md b/docs/workers.md index 4bd60ba0a0..1b5d94f5eb 100644 --- a/docs/workers.md +++ b/docs/workers.md @@ -196,7 +196,7 @@ Handles the media repository. It can handle all endpoints starting with: /_matrix/media/ -And the following regular expressions matching media-specific administration APIs: +... and the following regular expressions matching media-specific administration APIs: ^/_synapse/admin/v1/purge_media_cache$ ^/_synapse/admin/v1/room/.*/media$ @@ -206,6 +206,18 @@ You should also set `enable_media_repo: False` in the shared configuration file to stop the main synapse running background jobs related to managing the media repository. +In the `media_repository` worker configuration file, configure the http listener to +expose the `media` resource. For example: + +```yaml + worker_listeners: + - type: http + port: 8085 + resources: + - names: + - media +``` + Note this worker cannot be load-balanced: only one instance should be active. ### `synapse.app.client_reader` From 29794c6bc84b9ba76f041bbc8a180b7421996004 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 20 Dec 2019 10:58:07 +0000 Subject: [PATCH 3/7] 1.7.2 --- CHANGES.md | 12 ++++++++++++ changelog.d/6576.bugfix | 1 - changelog.d/6578.bugfix | 1 - debian/changelog | 6 ++++++ synapse/__init__.py | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) delete mode 100644 changelog.d/6576.bugfix delete mode 100644 changelog.d/6578.bugfix diff --git a/CHANGES.md b/CHANGES.md index 7927714a36..d6567e24d2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,15 @@ +Synapse 1.7.2 (2019-12-20) +========================== + +This release fixes some regressions introduced in Synapse 1.7.0 and 1.7.1. + +Bugfixes +-------- + +- Fix a regression introduced in Synapse 1.7.1 which caused errors when attempting to backfill rooms over federation. ([\#6576](https://github.com/matrix-org/synapse/issues/6576)) +- Fix a bug introduced in Synapse 1.7.0 which caused an error on startup when upgrading from versions before 1.3.0. ([\#6578](https://github.com/matrix-org/synapse/issues/6578)) + + Synapse 1.7.1 (2019-12-18) ========================== diff --git a/changelog.d/6576.bugfix b/changelog.d/6576.bugfix deleted file mode 100644 index f5414fce4d..0000000000 --- a/changelog.d/6576.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix errors when attempting to backfill rooms over federation. diff --git a/changelog.d/6578.bugfix b/changelog.d/6578.bugfix deleted file mode 100644 index fae55a4456..0000000000 --- a/changelog.d/6578.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix a bug introduced in Synapse 1.7.0 which caused an error on startup when upgrading from versions before 1.3.0. diff --git a/debian/changelog b/debian/changelog index e400619eb9..2492b5db92 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +matrix-synapse-py3 (1.7.2) stable; urgency=medium + + * New synapse release 1.7.2. + + -- Synapse Packaging team Fri, 20 Dec 2019 10:56:50 +0000 + matrix-synapse-py3 (1.7.1) stable; urgency=medium * New synapse release 1.7.1. diff --git a/synapse/__init__.py b/synapse/__init__.py index e951bab593..996101cf09 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -36,7 +36,7 @@ try: except ImportError: pass -__version__ = "1.7.1" +__version__ = "1.7.2" if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)): # We import here so that we don't have to install a bunch of deps when From b2db3828418282b3059f6a0d1b9af3ffa32b52f2 Mon Sep 17 00:00:00 2001 From: dopple <54467709+doppled@users.noreply.github.com> Date: Sun, 22 Dec 2019 14:16:56 -0800 Subject: [PATCH 4/7] Update reverse proxy file name (#6590) s/reverse_proxy.rst/reverse_proxy.md/ --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ae51d6ab39..2691dfc23d 100644 --- a/README.rst +++ b/README.rst @@ -393,4 +393,4 @@ something like the following in their logs:: 2019-09-11 19:32:04,271 - synapse.federation.transport.server - 288 - WARNING - GET-11752 - authenticate_request failed: 401: Invalid signature for server with key ed25519:a_EqML: Unable to verify signature for This is normally caused by a misconfiguration in your reverse-proxy. See -``_ and double-check that your settings are correct. +``_ and double-check that your settings are correct. From f03c877b32c33275f47ead9e1e01d700a8d049c0 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 24 Dec 2019 17:39:58 +0000 Subject: [PATCH 5/7] sample log config TODO: automate generation of this --- docs/sample_log_config.yaml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/sample_log_config.yaml diff --git a/docs/sample_log_config.yaml b/docs/sample_log_config.yaml new file mode 100644 index 0000000000..11e8f35f41 --- /dev/null +++ b/docs/sample_log_config.yaml @@ -0,0 +1,43 @@ +# Example log config file for synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema + +version: 1 + +formatters: + precise: + format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + +filters: + context: + (): synapse.logging.context.LoggingContextFilter + request: "" + +handlers: + file: + class: logging.handlers.RotatingFileHandler + formatter: precise + filename: /home/rav/work/synapse/homeserver.log + maxBytes: 104857600 + backupCount: 10 + filters: [context] + encoding: utf8 + console: + class: logging.StreamHandler + formatter: precise + filters: [context] + +loggers: + synapse.storage.SQL: + # beware: increasing this to DEBUG will make synapse log sensitive + # information such as access tokens. + level: INFO + +root: + level: INFO + handlers: [file, console] + +disable_existing_loggers: false From 92eac974b95c06868768f39f642361246f1c0b0f Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 31 Dec 2019 10:41:44 +0000 Subject: [PATCH 6/7] Hacks to work around #6605 (#6608) When we have an event which refers to non-existent auth_events, ignore said events rather than exploding in a ball of fire. Fixes #6605. --- changelog.d/6608.bugfix | 1 + synapse/state/v2.py | 52 +++++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 changelog.d/6608.bugfix diff --git a/changelog.d/6608.bugfix b/changelog.d/6608.bugfix new file mode 100644 index 0000000000..7768e0846e --- /dev/null +++ b/changelog.d/6608.bugfix @@ -0,0 +1 @@ +Fix exceptions caused by state resolution choking on malformed events. diff --git a/synapse/state/v2.py b/synapse/state/v2.py index cb77ed5b78..72fb8a6317 100644 --- a/synapse/state/v2.py +++ b/synapse/state/v2.py @@ -183,16 +183,20 @@ def _get_power_level_for_sender(room_id, event_id, event_map, state_res_store): pl = None for aid in event.auth_event_ids(): - aev = yield _get_event(room_id, aid, event_map, state_res_store) - if (aev.type, aev.state_key) == (EventTypes.PowerLevels, ""): + aev = yield _get_event( + room_id, aid, event_map, state_res_store, allow_none=True + ) + if aev and (aev.type, aev.state_key) == (EventTypes.PowerLevels, ""): pl = aev break if pl is None: # Couldn't find power level. Check if they're the creator of the room for aid in event.auth_event_ids(): - aev = yield _get_event(room_id, aid, event_map, state_res_store) - if (aev.type, aev.state_key) == (EventTypes.Create, ""): + aev = yield _get_event( + room_id, aid, event_map, state_res_store, allow_none=True + ) + if aev and (aev.type, aev.state_key) == (EventTypes.Create, ""): if aev.content.get("creator") == event.sender: return 100 break @@ -403,10 +407,17 @@ def _iterative_auth_checks( auth_events = {} for aid in event.auth_event_ids(): - ev = yield _get_event(room_id, aid, event_map, state_res_store) + ev = yield _get_event( + room_id, aid, event_map, state_res_store, allow_none=True + ) - if ev.rejected_reason is None: - auth_events[(ev.type, ev.state_key)] = ev + if not ev: + logger.warning( + "auth_event id %s for event %s is missing", aid, event_id + ) + else: + if ev.rejected_reason is None: + auth_events[(ev.type, ev.state_key)] = ev for key in event_auth.auth_types_for_event(event): if key in resolved_state: @@ -457,8 +468,10 @@ def _mainline_sort( auth_events = pl_ev.auth_event_ids() pl = None for aid in auth_events: - ev = yield _get_event(room_id, aid, event_map, state_res_store) - if (ev.type, ev.state_key) == (EventTypes.PowerLevels, ""): + ev = yield _get_event( + room_id, aid, event_map, state_res_store, allow_none=True + ) + if ev and (ev.type, ev.state_key) == (EventTypes.PowerLevels, ""): pl = aid break @@ -506,8 +519,10 @@ def _get_mainline_depth_for_event(event, mainline_map, event_map, state_res_stor event = None for aid in auth_events: - aev = yield _get_event(room_id, aid, event_map, state_res_store) - if (aev.type, aev.state_key) == (EventTypes.PowerLevels, ""): + aev = yield _get_event( + room_id, aid, event_map, state_res_store, allow_none=True + ) + if aev and (aev.type, aev.state_key) == (EventTypes.PowerLevels, ""): event = aev break @@ -516,7 +531,7 @@ def _get_mainline_depth_for_event(event, mainline_map, event_map, state_res_stor @defer.inlineCallbacks -def _get_event(room_id, event_id, event_map, state_res_store): +def _get_event(room_id, event_id, event_map, state_res_store, allow_none=False): """Helper function to look up event in event_map, falling back to looking it up in the store @@ -525,15 +540,22 @@ def _get_event(room_id, event_id, event_map, state_res_store): event_id (str) event_map (dict[str,FrozenEvent]) state_res_store (StateResolutionStore) + allow_none (bool): if the event is not found, return None rather than raising + an exception Returns: - Deferred[FrozenEvent] + Deferred[Optional[FrozenEvent]] """ if event_id not in event_map: events = yield state_res_store.get_events([event_id], allow_rejected=True) event_map.update(events) - event = event_map[event_id] - assert event is not None + event = event_map.get(event_id) + + if event is None: + if allow_none: + return None + raise Exception("Unknown event %s" % (event_id,)) + if event.room_id != room_id: raise Exception( "In state res for room %s, event %s is in %s" From 77661ce81a799a375317dff9e4c8696da528984c Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 31 Dec 2019 10:45:12 +0000 Subject: [PATCH 7/7] 1.7.3 --- CHANGES.md | 11 +++++++++++ changelog.d/6608.bugfix | 1 - debian/changelog | 6 ++++++ synapse/__init__.py | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) delete mode 100644 changelog.d/6608.bugfix diff --git a/CHANGES.md b/CHANGES.md index d6567e24d2..361fd1fc6c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,14 @@ +Synapse 1.7.3 (2019-12-31) +========================== + +This release fixes a long-standing bug in the state resolution algorithm. + +Bugfixes +-------- + +- Fix exceptions caused by state resolution choking on malformed events. ([\#6608](https://github.com/matrix-org/synapse/issues/6608)) + + Synapse 1.7.2 (2019-12-20) ========================== diff --git a/changelog.d/6608.bugfix b/changelog.d/6608.bugfix deleted file mode 100644 index 7768e0846e..0000000000 --- a/changelog.d/6608.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix exceptions caused by state resolution choking on malformed events. diff --git a/debian/changelog b/debian/changelog index 2492b5db92..31791c127c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +matrix-synapse-py3 (1.7.3) stable; urgency=medium + + * New synapse release 1.7.3. + + -- Synapse Packaging team Tue, 31 Dec 2019 10:45:04 +0000 + matrix-synapse-py3 (1.7.2) stable; urgency=medium * New synapse release 1.7.2. diff --git a/synapse/__init__.py b/synapse/__init__.py index 996101cf09..71cb611820 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -36,7 +36,7 @@ try: except ImportError: pass -__version__ = "1.7.2" +__version__ = "1.7.3" if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)): # We import here so that we don't have to install a bunch of deps when