diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2022-03-01 15:27:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-01 15:27:15 +0000 |
commit | 4d6b6c17c860a6ef258e513d841dbda6ea151cbd (patch) | |
tree | 1ab3f9180e5b6f1931d442536dc63559a1950420 /synapse/util/async_helpers.py | |
parent | Add module callbacks called for reacting to deactivation status change and pr... (diff) | |
download | synapse-4d6b6c17c860a6ef258e513d841dbda6ea151cbd.tar.xz |
Fix rare error in `ReadWriteLock` when writers complete immediately (#12105)
Signed-off-by: Sean Quah <seanq@element.io>
Diffstat (limited to 'synapse/util/async_helpers.py')
-rw-r--r-- | synapse/util/async_helpers.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/synapse/util/async_helpers.py b/synapse/util/async_helpers.py index 81320b8972..60c03a66fd 100644 --- a/synapse/util/async_helpers.py +++ b/synapse/util/async_helpers.py @@ -555,7 +555,10 @@ class ReadWriteLock: finally: with PreserveLoggingContext(): new_defer.callback(None) - if self.key_to_current_writer[key] == new_defer: + # `self.key_to_current_writer[key]` may be missing if there was another + # writer waiting for us and it completed entirely within the + # `new_defer.callback()` call above. + if self.key_to_current_writer.get(key) == new_defer: self.key_to_current_writer.pop(key) return _ctx_manager() |