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

log: add a mutex for stderr redirection #49936

Merged
merged 1 commit into from
Jun 6, 2020

Conversation

knz
Copy link
Contributor

@knz knz commented Jun 6, 2020

Fixes #49930

The TestLogScope infrastructure is meant to force-configure logging
to go to a temporary directory. It was designed with the assumption it
would be used "outside" of server initialization, i.e.
non-concurrently with log API calls.

However, at least one test (TestHBAAuthenticationRules) violates the
assumption and switches the output directory while a server is running.

After checking it appears that the behavior is sound, but there was
one racy access remaining: the write to os.Stderr during the
redirect.

This had been racy ever since TestLogScope was introduced; however
it was only visible on windows because the unix builds were missing
the assignment to os.Stderr. A recent fix to make the builds
consistent revealed the race to our CI checker.

This patch fixes it by adding the missing mutex.

Release note: None

@knz knz requested a review from tbg June 6, 2020 11:43
@cockroach-teamcity
Copy link
Member

This change is Reviewable

The `TestLogScope` infrastructure is meant to force-configure logging
to go to a temporary directory. It was designed with the assumption it
would be used "outside" of server initialization, i.e.
non-concurrently with `log` API calls.

However, at least one test (`TestHBAAuthenticationRules`) violates the
assumption and switches the output directory while a server is running.

After checking it appears that the behavior is sound, but there was
one racy access remaining: the write to `os.Stderr` during the
redirect.

This had been racy ever since TestLogScope was introduced; however
it was only visible on windows because the unix builds were missing
the assignment to `os.Stderr`. A recent fix to make the builds
consistent revealed the race to our CI checker.

This patch fixes it by adding the missing mutex.

Release note: None
@knz
Copy link
Contributor Author

knz commented Jun 6, 2020

thx

bors r=tbg

@craig
Copy link
Contributor

craig bot commented Jun 6, 2020

Build succeeded

@craig craig bot merged commit f4a9f52 into cockroachdb:master Jun 6, 2020
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.

sql/pgwire: TestAuthenticationAndHBARules failed
3 participants