-
Notifications
You must be signed in to change notification settings - Fork 480
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
Data race fix for context slog.Logger #1193
base: main
Are you sure you want to change the base?
Conversation
See tus#1192 This adds a mock slog Logger to create a data race issue. Run go test -race to trigger
This fix adds two possible solutions to the data race issue. We either add the "id" info manually when logging, or we create a function-scoped logger based on the initial logger. The context logger must not be mutated.
Thank you for looking into this! As mentioned in #1192 (comment), it's probably easier to set the |
@wongak I enabled the race detector for CI in this PR and reverted your fix (for now) in an attempt to reproduce this race warning. However, neither locally nor on CI is the |
I can't reproduce it either. Which is a bit confusing. I got the errors before applying your changes. But with your fixes, it seems to be fine. |
The data race report from your original comment mentions the use of
I wonder if this warning appears when the context is accessed by the data store, for example. But if you cannot reproduce this anymore, we can also close this issue since the other data races have been addressed. |
See #1192
This adds a mock slog Logger to create a data race issue. Run go test -race to trigger.
I am currently thinking about different approaches for a fix. But it's a bit complicated.
The way
httpContext
is implemented does not allow any mutations. It would need to be cloned, and any requests would need to be copied as well withhttp.Request.WithContext
to contain the httpContext.