Open viv2793 opened 1 year ago
Are you sure you are not putting in corrupted context.Contexts? We can into this
By context.Context corruption, interface assignments are not atomic, so a common mistake I've seen in Uber is not assigning a new context in a goroutine from an outer scoped parent context.
Consider: https://go.dev/play/p/BpJcv5_Nu-2
Issue tracker is used for reporting bugs and discussing new features. Please use stackoverflow for supporting issues.
Expected Behavior
Data race should not happen
Current Behavior
We are getting data race when we are using ctx.Done(). We are using context to pass some
key:value
pairs across functions. But sometimes we get this data race in case of ctx.Done()Possible Solution
Steps to Reproduce
We are not able to able to reproduce this every time. And right now, we are not sure of how we can reproduce it.
The only thing that I can share is that we are using context to pass some
key:value
pairs across functions. But sometimes we get this data race in case of ctx.Done()func SetAgentID(ctx context.Context, agentID string) context.Context { return context.WithValue(ctx, log.AgentIDKey, agentID) }