Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

run_in_background calls whose return value is discarded can re-start finished logging contexts #13090

Open
squahtx opened this issue Jun 16, 2022 · 1 comment
Labels
S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@squahtx
Copy link
Contributor

squahtx commented Jun 16, 2022

A more general version of #12987.

When we launch a task using run_in_background, the task inherits the current logging context. If we neglect to await the task, we may finish our current logging context while the background task is still using it. We ought to either await such background tasks or give them their own logging contexts.

clokep notes that we can find such calls using grep -r " run_in_background" synapse and there are a few places we do so.

Note that it does not make sense to write await make_deferred_yieldable(run_in_background(f, ...)), as it could be written as await f(...).

@squahtx squahtx added S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Jun 16, 2022
@clokep
Copy link
Member

clokep commented Jun 17, 2022

clokep notes that we can find such calls using grep -r " run_in_background" synapse and there are a few places we do so.

Just note that you want two spaces before the run_in_background, GitHub (or HTML?) seems to be collapsing them...

squahtx pushed a commit that referenced this issue Jan 31, 2023
`run_in_background` calls re-use the current logging context. When they
are not awaited, they can complete after the current logging context has
been marked as finished, which leads to log spam. Use
`run_as_background_process` instead.

Fixes one of the instances of #13090.

Signed-off-by: Sean Quah <[email protected]>
squahtx added a commit that referenced this issue Jan 31, 2023
)

`run_in_background` calls re-use the current logging context. When they
are not awaited, they can complete after the current logging context has
been marked as finished, which leads to log spam. Use
`run_as_background_process` instead.

Fixes one of the instances of #13090.

Signed-off-by: Sean Quah <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

No branches or pull requests

2 participants