Skip to content
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

attributes: avoid the use of %#v formatting verb #6664

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Sep 25, 2023

The %#v formatting verb looks deep into structs which are passed by pointer as well. This means that if a struct contains a sync.Mutex and is a key or value in the attributes, then printing the attributes 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 the attributes, this is much better than having flaky tests.

RELEASE NOTES: none

@easwars easwars requested a review from dfawley September 25, 2023 23:25
@easwars easwars added this to the 1.59 Release milestone Sep 25, 2023
@dfawley dfawley assigned easwars and unassigned dfawley Sep 25, 2023
@easwars easwars merged commit 5e4402f into grpc:master Sep 26, 2023
10 checks passed
@easwars easwars deleted the flaky_test_attributes_printing branch September 26, 2023 16:58
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants