-
Notifications
You must be signed in to change notification settings - Fork 414
Fix run_in_background not be awaited properly causing LoggingContext problems
#18937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix run_in_background not be awaited properly causing LoggingContext problems
#18937
Conversation
This reverts commit c582067.
…ess(...)`" This reverts commit 589c518.
The only reason I can see why this might have been added was to avoid these kind of warnings: ``` Starting metrics collection 'xxx' from sentinel context: metrics will be lost ``` But it's expected that things run outside of Synapse should happen in the sentinel logcontext
| room_version, | ||
| ) | ||
|
|
||
| with LoggingContext("send_rejected"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally tried adapting things to keep these LoggingContext around but then realized there is no point in having these here in the tests.
The only reason I can see why this might have been added was to avoid these kind of warnings in _trial_temp/test.log:
Starting metrics collection 'xxx' from sentinel context: metrics will be lost
But it's expected that test things run outside of Synapse and by their nature should happen in the sentinel logcontext. And if we really don't want to see these kind of errors, we would need to refactor get_success(...) to look more like get_success(func, OTHER_SERVER, ev) where we call the function with some homeserver_test_case logcontext instead of passing in an awaitable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible the name was added here for logging clarity, to be fair?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that was the original reason but with a more nailed down definition of sentinel logcontext and when it should be used, I don't think it makes sense.
And after working with logcontext a bunch, I've kinda come to the conclusion that the name doesn't matter much outside of a request. Or at-least doesn't matter much to what I'm trying to accomplish.
| room_version, | ||
| ) | ||
|
|
||
| with LoggingContext("send_rejected"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible the name was added here for logging clarity, to be fair?
|
Thanks for the review @reivilibre 🦜 |
Fix
run_in_backgroundnot be awaited properly causingLoggingContextproblemsBasically, searching for any instance of
run_in_background(...)and making sure we wrap the deferred inmake_deferred_yieldable(...)if we try toawaitthe result to make it follow the Synapse logcontext rules.Turns out, we only have this problem in some tests (phew)
Part of #18905
Dev notes
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.