attributes: avoid the use of %#v formatting verb #6664
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
%#v
formatting verb looks deep into structs which are passed by pointer as well. This means that if a struct contains async.Mutex
and is a key or value in theattributes
, then printing theattributes
with the%#v
verb will result in the fields of this struct being accessed without holding the mutex.While this does not introduce correctness issues in the code (we might end up with inconsistent data in the log messages where the
attributes
are printed), this causes our tests to be super flaky when run with the go race detector. And it wasn't straight-forward to figure out why the race was happening when looking at the stack traces reported by the race detector.This PR eliminates this race by using the
%p
verb that we were using earlier. While this results in some sub-optimal logging output of theattributes
, this is much better than having flaky tests.RELEASE NOTES: none