diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2022-04-05 17:19:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 17:19:16 +0100 |
commit | 79e7c2c42648b189b800b80fcdb61949ab9be51b (patch) | |
tree | a472a39d22413e5af8fc8b3e970cdb08cb69e9ea /synapse | |
parent | Make `StreamToken` and `RoomStreamToken` methods propagate cancellations (#12... (diff) | |
download | synapse-79e7c2c42648b189b800b80fcdb61949ab9be51b.tar.xz |
Fix edge case where a `Linearizer` could get stuck (#12358)
Just after a task acquires a contended `Linearizer` lock, it sleeps. If the task is cancelled during this sleep, we need to release the lock. Signed-off-by: Sean Quah <seanq@element.io>
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/util/async_helpers.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/util/async_helpers.py b/synapse/util/async_helpers.py index 4b2a16a6a9..650e44de22 100644 --- a/synapse/util/async_helpers.py +++ b/synapse/util/async_helpers.py @@ -453,7 +453,11 @@ class Linearizer: # # This needs to happen while we hold the lock. We could put it on the # exit path, but that would slow down the uncontended case. - await self._clock.sleep(0) + try: + await self._clock.sleep(0) + except CancelledError: + self._release_lock(key, entry) + raise return entry |