From d9bd62f9d1a6238b3f485caee07f9fd399b27134 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Wed, 21 Apr 2021 16:39:34 +0100 Subject: [PATCH 1/6] Make LoggingContext's name optional (#9857) Fixes https://github.com/matrix-org/synapse-s3-storage-provider/issues/55 --- changelog.d/9857.bugfix | 1 + synapse/logging/context.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelog.d/9857.bugfix diff --git a/changelog.d/9857.bugfix b/changelog.d/9857.bugfix new file mode 100644 index 000000000..7eed41594 --- /dev/null +++ b/changelog.d/9857.bugfix @@ -0,0 +1 @@ +Fix a regression in Synapse v1.32.1 which caused `LoggingContext` errors in plugins. diff --git a/synapse/logging/context.py b/synapse/logging/context.py index dbd7d3a33..7fc11a9ac 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -258,7 +258,8 @@ class LoggingContext: child to the parent Args: - name (str): Name for the context for debugging. + name: Name for the context for logging. If this is omitted, it is + inherited from the parent context. parent_context (LoggingContext|None): The parent of the new context """ @@ -277,12 +278,11 @@ class LoggingContext: def __init__( self, - name: str, + name: Optional[str] = None, parent_context: "Optional[LoggingContext]" = None, request: Optional[ContextRequest] = None, ) -> None: self.previous_context = current_context() - self.name = name # track the resources used by this context so far self._resource_usage = ContextResourceUsage() @@ -314,6 +314,15 @@ class LoggingContext: # the request param overrides the request from the parent context self.request = request + # if we don't have a `name`, but do have a parent context, use its name. + if self.parent_context and name is None: + name = str(self.parent_context) + if name is None: + raise ValueError( + "LoggingContext must be given either a name or a parent context" + ) + self.name = name + def __str__(self) -> str: return self.name From 0c23aa393cf5f26a9a49267d113767ffcf82d58f Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Wed, 21 Apr 2021 18:16:58 +0100 Subject: [PATCH 2/6] Note LoggingContext signature change incompatibility in 1.32.0 (#9859) 1.32.0 also introduced an incompatibility with Synapse modules that make use of `synapse.logging.context.LoggingContext`, such as [synapse-s3-storage-provider](https://github.com/matrix-org/synapse-s3-storage-provider). This PR adds a note to the 1.32.0 changelog and upgrade notes about it. --- CHANGES.md | 17 ++++++++++++----- UPGRADE.rst | 8 ++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7188f9444..a1349252c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,10 +2,10 @@ Synapse 1.32.1 (2021-04-21) =========================== This release fixes [a regression](https://github.com/matrix-org/synapse/issues/9853) -in Synapse 1.32.0 that caused connected Prometheus instances to become unstable. If you -ran Synapse 1.32.0 with Prometheus metrics, first upgrade to Synapse 1.32.1 and follow -[these instructions](https://github.com/matrix-org/synapse/pull/9854#issuecomment-823472183) -to clean up any excess writeahead logs. +in Synapse 1.32.0 that caused connected Prometheus instances to become unstable. + +However, as this release is still subject to the `LoggingContext` change in 1.32.0, +it is recommended to remain on or downgrade to 1.31.0. Bugfixes -------- @@ -18,7 +18,14 @@ Synapse 1.32.0 (2021-04-20) **Note:** This release introduces [a regression](https://github.com/matrix-org/synapse/issues/9853) that can overwhelm connected Prometheus instances. This issue was not present in -1.32.0rc1, and is fixed in 1.32.1. See the changelog for 1.32.1 above for more information. +1.32.0rc1. If affected, it is recommended to downgrade to 1.31.0 in the meantime, and +follow [these instructions](https://github.com/matrix-org/synapse/pull/9854#issuecomment-823472183) +to clean up any excess writeahead logs. + +**Note:** This release also mistakenly included a change that may affected Synapse +modules that import `synapse.logging.context.LoggingContext`, such as +[synapse-s3-storage-provider](https://github.com/matrix-org/synapse-s3-storage-provider). +This will be fixed in a later Synapse version. **Note:** This release requires Python 3.6+ and Postgres 9.6+ or SQLite 3.22+. diff --git a/UPGRADE.rst b/UPGRADE.rst index 76d2ee394..6af35bc38 100644 --- a/UPGRADE.rst +++ b/UPGRADE.rst @@ -93,11 +93,11 @@ Regression causing connected Prometheus instances to become overwhelmed This release introduces `a regression `_ that can overwhelm connected Prometheus instances. This issue is not present in -Synapse v1.32.0rc1, and is fixed in Synapse v1.32.1. +Synapse v1.32.0rc1. -If you have been affected, please first upgrade to a more recent Synapse version. -You then may need to remove excess writeahead logs in order for Prometheus to recover. -Instructions for doing so are provided +If you have been affected, please downgrade to 1.31.0. You then may need to +remove excess writeahead logs in order for Prometheus to recover. Instructions +for doing so are provided `here `_. Dropping support for old Python, Postgres and SQLite versions From 55159c48e31129c87b55d15d203df946ca33f884 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 21 Apr 2021 18:45:39 +0100 Subject: [PATCH 3/6] 1.32.2 --- CHANGES.md | 11 +++++++++++ changelog.d/9857.bugfix | 1 - debian/changelog | 6 ++++++ synapse/__init__.py | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) delete mode 100644 changelog.d/9857.bugfix diff --git a/CHANGES.md b/CHANGES.md index a1349252c..f194f4db3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,14 @@ +Synapse 1.32.2 (2021-04-21) +=========================== + +This release includes fixes for the two regressions introduced in 1.32.0. + +Bugfixes +-------- + +- Fix a regression in Synapse v1.32.1 which caused `LoggingContext` errors in plugins. ([\#9857](https://github.com/matrix-org/synapse/issues/9857)) + + Synapse 1.32.1 (2021-04-21) =========================== diff --git a/changelog.d/9857.bugfix b/changelog.d/9857.bugfix deleted file mode 100644 index 7eed41594..000000000 --- a/changelog.d/9857.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix a regression in Synapse v1.32.1 which caused `LoggingContext` errors in plugins. diff --git a/debian/changelog b/debian/changelog index b8cf2cac5..9ebfc3c3f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +matrix-synapse-py3 (1.32.2) stable; urgency=medium + + * New synapse release 1.32.2. + + -- Synapse Packaging team Wed, 21 Apr 2021 18:43:52 +0100 + matrix-synapse-py3 (1.32.1) stable; urgency=medium * New synapse release 1.32.1. diff --git a/synapse/__init__.py b/synapse/__init__.py index a0332d602..781f5ac3a 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -48,7 +48,7 @@ try: except ImportError: pass -__version__ = "1.32.1" +__version__ = "1.32.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 ca380881b16847f61b323424aceb65548180d624 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 21 Apr 2021 18:47:31 +0100 Subject: [PATCH 4/6] Update dates in changelogs --- CHANGES.md | 2 +- debian/changelog | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f194f4db3..7475f7a40 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -Synapse 1.32.2 (2021-04-21) +Synapse 1.32.2 (2021-04-22) =========================== This release includes fixes for the two regressions introduced in 1.32.0. diff --git a/debian/changelog b/debian/changelog index 9ebfc3c3f..fd33bfda5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ matrix-synapse-py3 (1.32.2) stable; urgency=medium * New synapse release 1.32.2. - -- Synapse Packaging team Wed, 21 Apr 2021 18:43:52 +0100 + -- Synapse Packaging team Wed, 22 Apr 2021 12:43:52 +0100 matrix-synapse-py3 (1.32.1) stable; urgency=medium From 79e6d9e4b1d6231ebdb9b4e8d1bd5e382c37f26e Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 22 Apr 2021 11:04:51 +0100 Subject: [PATCH 5/6] Note regression was in 1.32.0 and 1.32.1 --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7475f7a40..8381b3112 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,12 +1,12 @@ Synapse 1.32.2 (2021-04-22) =========================== -This release includes fixes for the two regressions introduced in 1.32.0. +This release includes a fix for a regression introduced in 1.32.0 and 1.32.1. Bugfixes -------- -- Fix a regression in Synapse v1.32.1 which caused `LoggingContext` errors in plugins. ([\#9857](https://github.com/matrix-org/synapse/issues/9857)) +- Fix a regression in Synapse 1.32.1 which caused `LoggingContext` errors in plugins. ([\#9857](https://github.com/matrix-org/synapse/issues/9857)) Synapse 1.32.1 (2021-04-21) From dac44459348bd1d771a2dd6970f2a9e6532ee85f Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 22 Apr 2021 11:09:31 +0100 Subject: [PATCH 6/6] A regression can't be introduced twice --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8381b3112..532b30e23 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,12 +1,12 @@ Synapse 1.32.2 (2021-04-22) =========================== -This release includes a fix for a regression introduced in 1.32.0 and 1.32.1. +This release includes a fix for a regression introduced in 1.32.0. Bugfixes -------- -- Fix a regression in Synapse 1.32.1 which caused `LoggingContext` errors in plugins. ([\#9857](https://github.com/matrix-org/synapse/issues/9857)) +- Fix a regression in Synapse 1.32.0 and 1.32.1 which caused `LoggingContext` errors in plugins. ([\#9857](https://github.com/matrix-org/synapse/issues/9857)) Synapse 1.32.1 (2021-04-21)