Skip to content

Keep withLoggingContextAsync entries off the thread MDC - #608

Open
timobraveweber wants to merge 1 commit into
oshai:masterfrom
timobraveweber:fix-async-mdc-leak
Open

timobraveweber wants to merge 1 commit into
oshai:masterfrom
timobraveweber:fix-async-mdc-leak

Conversation

@timobraveweber

Copy link
Copy Markdown

withLoggingContextAsync puts its entries into the MDC of the current thread before it switches to an MDCContext. A body that resumes on another thread leaves the entries on the first thread. The cleanup then writes the previous values onto the second thread.

Unrelated work on either thread logs with these entries.

The function now builds the MDCContext from the current MDC plus the entries. It no longer writes the thread's MDC before the body. The three overloads are no longer inline, so a later fix reaches callers without a recompile. Callers compiled against 8.0.4 keep the old inlined code until they recompile.

Fixes #607

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withLoggingContextAsync leaves MDC entries on the thread where the block started

1 participant