This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Error on shutdown when prescence is enabled #11517
Copy link
Copy link
Closed
Labels
S-TolerableMinor significance, cosmetic issues, low or no impact to users.Minor significance, cosmetic issues, low or no impact to users.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Description
Spotted when I was reading through sytest logs.
21082-2021-12-06 18:04:19,715 - synapse.metrics.background_process_metrics - 246 - ERROR - generic_presence.on_shutdown-0 - Background process 'generic_presence.on_shutdown' threw an exception
21083-Traceback (most recent call last):
21084- File "/venv/lib/python3.7/site-packages/synapse/metrics/background_process_metrics.py", line 242, in run
21085- return await func(*args, **kwargs)
21086-TypeError: object NoneType can't be used in 'await' expression
The problem is that we register a call to run_as_background_process
before shutdown here. We pass it the callable self._on_shutdown
. The latter is a synchronous function, but run_as_background_process
expects an async function.
synapse/synapse/handlers/presence.py
Lines 416 to 428 in 75ca0a6
hs.get_reactor().addSystemEventTrigger( | |
"before", | |
"shutdown", | |
run_as_background_process, | |
"generic_presence.on_shutdown", | |
self._on_shutdown, | |
) | |
def _on_shutdown(self) -> None: | |
if self._presence_enabled: | |
self.hs.get_tcp_replication().send_command( | |
ClearUserSyncsCommand(self.instance_id) | |
) |
The symptom was introduced in #10847 when we removed maybe_awaitable
. But the underlying cause is that _on_shutdown
didn't return a Deferred back when we expected it to. (Plus addSystemEventTrigger
obscures the call from mypy. Probably extra confusion when this was rewritten from twisted defers to asyncs.)
Metadata
Metadata
Assignees
Labels
S-TolerableMinor significance, cosmetic issues, low or no impact to users.Minor significance, cosmetic issues, low or no impact to users.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.Bugs, crashes, hangs, security vulnerabilities, or other reported issues.