Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 06690b1

Browse files
committed
Merge tag 'v1.32.2' into babolivier/dinsic_1.41.0
Synapse 1.32.2 (2021-04-22) =========================== This release includes a fix for a regression introduced in 1.32.0. Bugfixes -------- - Fix a regression in Synapse 1.32.0 and 1.32.1 which caused `LoggingContext` errors in plugins. ([\#9857](matrix-org/synapse#9857))
2 parents 9de3991 + dac4445 commit 06690b1

File tree

7 files changed

+100
-9
lines changed

7 files changed

+100
-9
lines changed

CHANGES.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
1+
Synapse 1.32.2 (2021-04-22)
2+
===========================
3+
4+
This release includes a fix for a regression introduced in 1.32.0.
5+
6+
Bugfixes
7+
--------
8+
9+
- 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))
10+
11+
12+
Synapse 1.32.1 (2021-04-21)
13+
===========================
14+
15+
This release fixes [a regression](https://github.com/matrix-org/synapse/issues/9853)
16+
in Synapse 1.32.0 that caused connected Prometheus instances to become unstable.
17+
18+
However, as this release is still subject to the `LoggingContext` change in 1.32.0,
19+
it is recommended to remain on or downgrade to 1.31.0.
20+
21+
Bugfixes
22+
--------
23+
24+
- Fix a regression in Synapse 1.32.0 which caused Synapse to report large numbers of Prometheus time series, potentially overwhelming Prometheus instances. ([\#9854](https://github.com/matrix-org/synapse/issues/9854))
25+
26+
127
Synapse 1.32.0 (2021-04-20)
228
===========================
329

30+
**Note:** This release introduces [a regression](https://github.com/matrix-org/synapse/issues/9853)
31+
that can overwhelm connected Prometheus instances. This issue was not present in
32+
1.32.0rc1. If affected, it is recommended to downgrade to 1.31.0 in the meantime, and
33+
follow [these instructions](https://github.com/matrix-org/synapse/pull/9854#issuecomment-823472183)
34+
to clean up any excess writeahead logs.
35+
36+
**Note:** This release also mistakenly included a change that may affected Synapse
37+
modules that import `synapse.logging.context.LoggingContext`, such as
38+
[synapse-s3-storage-provider](https://github.com/matrix-org/synapse-s3-storage-provider).
39+
This will be fixed in a later Synapse version.
40+
441
**Note:** This release requires Python 3.6+ and Postgres 9.6+ or SQLite 3.22+.
542

643
This release removes the deprecated `GET /_synapse/admin/v1/users/<user_id>` admin API. Please use the [v2 API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/user_admin_api.rst#query-user-account) instead, which has improved capabilities.
744

845
This release requires Application Services to use type `m.login.application_service` when registering users via the `/_matrix/client/r0/register` endpoint to comply with the spec. Please ensure your Application Services are up to date.
946

47+
If you are using the `packages.matrix.org` Debian repository for Synapse packages,
48+
note that we have recently updated the expiry date on the gpg signing key. If you see an
49+
error similar to `The following signatures were invalid: EXPKEYSIG F473DD4473365DE1`, you
50+
will need to get a fresh copy of the keys. You can do so with:
51+
52+
```sh
53+
sudo wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg
54+
```
55+
1056
Bugfixes
1157
--------
1258

UPGRADE.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ for example:
8888
Upgrading to v1.32.0
8989
====================
9090

91+
Regression causing connected Prometheus instances to become overwhelmed
92+
-----------------------------------------------------------------------
93+
94+
This release introduces `a regression <https://github.com/matrix-org/synapse/issues/9853>`_
95+
that can overwhelm connected Prometheus instances. This issue is not present in
96+
Synapse v1.32.0rc1.
97+
98+
If you have been affected, please downgrade to 1.31.0. You then may need to
99+
remove excess writeahead logs in order for Prometheus to recover. Instructions
100+
for doing so are provided
101+
`here <https://github.com/matrix-org/synapse/pull/9854#issuecomment-823472183>`_.
102+
91103
Dropping support for old Python, Postgres and SQLite versions
92104
-------------------------------------------------------------
93105

debian/changelog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
matrix-synapse-py3 (1.32.2) stable; urgency=medium
2+
3+
* New synapse release 1.32.2.
4+
5+
-- Synapse Packaging team <[email protected]> Wed, 22 Apr 2021 12:43:52 +0100
6+
7+
matrix-synapse-py3 (1.32.1) stable; urgency=medium
8+
9+
* New synapse release 1.32.1.
10+
11+
-- Synapse Packaging team <[email protected]> Wed, 21 Apr 2021 14:00:55 +0100
12+
113
matrix-synapse-py3 (1.32.0) stable; urgency=medium
214

315
[ Dan Callahan ]

synapse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
except ImportError:
4949
pass
5050

51-
__version__ = "1.32.0"
51+
__version__ = "1.32.2"
5252

5353
if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)):
5454
# We import here so that we don't have to install a bunch of deps when

synapse/logging/context.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ class LoggingContext:
258258
child to the parent
259259
260260
Args:
261-
name (str): Name for the context for debugging.
261+
name: Name for the context for logging. If this is omitted, it is
262+
inherited from the parent context.
262263
parent_context (LoggingContext|None): The parent of the new context
263264
"""
264265

@@ -277,12 +278,11 @@ class LoggingContext:
277278

278279
def __init__(
279280
self,
280-
name: str,
281+
name: Optional[str] = None,
281282
parent_context: "Optional[LoggingContext]" = None,
282283
request: Optional[ContextRequest] = None,
283284
) -> None:
284285
self.previous_context = current_context()
285-
self.name = name
286286

287287
# track the resources used by this context so far
288288
self._resource_usage = ContextResourceUsage()
@@ -314,6 +314,15 @@ def __init__(
314314
# the request param overrides the request from the parent context
315315
self.request = request
316316

317+
# if we don't have a `name`, but do have a parent context, use its name.
318+
if self.parent_context and name is None:
319+
name = str(self.parent_context)
320+
if name is None:
321+
raise ValueError(
322+
"LoggingContext must be given either a name or a parent context"
323+
)
324+
self.name = name
325+
317326
def __str__(self) -> str:
318327
return self.name
319328

synapse/metrics/background_process_metrics.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import logging
1717
import threading
1818
from functools import wraps
19-
from typing import TYPE_CHECKING, Dict, Optional, Set
19+
from typing import TYPE_CHECKING, Dict, Optional, Set, Union
2020

2121
from prometheus_client.core import REGISTRY, Counter, Gauge
2222

@@ -199,7 +199,7 @@ async def run():
199199
_background_process_start_count.labels(desc).inc()
200200
_background_process_in_flight_count.labels(desc).inc()
201201

202-
with BackgroundProcessLoggingContext("%s-%s" % (desc, count)) as context:
202+
with BackgroundProcessLoggingContext(desc, count) as context:
203203
try:
204204
ctx = noop_context_manager()
205205
if bg_start_span:
@@ -244,8 +244,20 @@ class BackgroundProcessLoggingContext(LoggingContext):
244244

245245
__slots__ = ["_proc"]
246246

247-
def __init__(self, name: str):
248-
super().__init__(name)
247+
def __init__(self, name: str, instance_id: Optional[Union[int, str]] = None):
248+
"""
249+
250+
Args:
251+
name: The name of the background process. Each distinct `name` gets a
252+
separate prometheus time series.
253+
254+
instance_id: an identifer to add to `name` to distinguish this instance of
255+
the named background process in the logs. If this is `None`, one is
256+
made up based on id(self).
257+
"""
258+
if instance_id is None:
259+
instance_id = id(self)
260+
super().__init__("%s-%s" % (name, instance_id))
249261
self._proc = _BackgroundProcess(name, self)
250262

251263
def start(self, rusage: "Optional[resource._RUsage]"):

synapse/replication/tcp/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def __init__(self, clock: Clock, handler: "ReplicationCommandHandler"):
185185
# a logcontext which we use for processing incoming commands. We declare it as a
186186
# background process so that the CPU stats get reported to prometheus.
187187
self._logging_context = BackgroundProcessLoggingContext(
188-
"replication-conn-%s" % (self.conn_id,)
188+
"replication-conn", self.conn_id
189189
)
190190

191191
def connectionMade(self):

0 commit comments

Comments
 (0)