Skip to content
Snippets Groups Projects
Unverified Commit 49a683d8 authored by Sean Quah's avatar Sean Quah Committed by GitHub
Browse files

Fix long-standing bug where `ReadWriteLock` could drop logging contexts (#10993)

Use `PreserveLoggingContext()` to ensure that logging contexts are not
lost when exiting a read/write lock.

When exiting a read/write lock, callbacks on a `Deferred` are triggered
as a signal to any waiting coroutines. Any waiting coroutine that
becomes runnable is likely to follow the Synapse logging context rules
and will restore its own logging context, then either run to completion
or await another `Deferred`, resetting the logging context in the
process.
parent bb228f35
No related branches found
No related tags found
No related merge requests found
Fix a long-standing bug where `ReadWriteLock`s could drop logging contexts on exit.
......@@ -438,7 +438,8 @@ class ReadWriteLock:
try:
yield
finally:
new_defer.callback(None)
with PreserveLoggingContext():
new_defer.callback(None)
self.key_to_current_readers.get(key, set()).discard(new_defer)
return _ctx_manager()
......@@ -466,7 +467,8 @@ class ReadWriteLock:
try:
yield
finally:
new_defer.callback(None)
with PreserveLoggingContext():
new_defer.callback(None)
if self.key_to_current_writer[key] == new_defer:
self.key_to_current_writer.pop(key)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment