From e575a34beb9b685eda3ff0aff1664cb7436f851f Mon Sep 17 00:00:00 2001 From: Sean Quah Date: Mon, 30 Jan 2023 23:41:26 +0000 Subject: [PATCH 1/2] Fix "Re-starting finished log context" spam when creating events `run_in_background` calls re-use the current logging context. When they are not awaited, they can complete after the current logging context has been marked as finished, which leads to log spam. Use `run_as_background_process` instead. Fixes one of the instances of #13090. Signed-off-by: Sean Quah --- changelog.d/14946.bugfix | 1 + synapse/handlers/message.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog.d/14946.bugfix diff --git a/changelog.d/14946.bugfix b/changelog.d/14946.bugfix new file mode 100644 index 000000000000..b9e768c44c83 --- /dev/null +++ b/changelog.d/14946.bugfix @@ -0,0 +1 @@ +Fix a long-standing bug where sending messages on servers with presence enabled would spam "Re-starting finished log context" log lines. diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 3278a695ed61..7c30e11e2c2f 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -1939,7 +1939,9 @@ async def persist_and_notify_client_events( if event.type == EventTypes.Message: # We don't want to block sending messages on any presence code. This # matters as sometimes presence code can take a while. - run_in_background(self._bump_active_time, requester.user) + run_as_background_process( + "bump_presence_active_time", self._bump_active_time, requester.user + ) async def _notify() -> None: try: From b2bfe134281d05530a7b426aec290fa8c5fe20e7 Mon Sep 17 00:00:00 2001 From: Sean Quah Date: Tue, 31 Jan 2023 00:46:39 +0000 Subject: [PATCH 2/2] fixup newsfile --- changelog.d/{14946.bugfix => 14947.bugfix} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{14946.bugfix => 14947.bugfix} (100%) diff --git a/changelog.d/14946.bugfix b/changelog.d/14947.bugfix similarity index 100% rename from changelog.d/14946.bugfix rename to changelog.d/14947.bugfix