Skip to content

fix: add mutex to MockAuditor export to prevent race #5189

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

Merged
merged 1 commit into from
Nov 30, 2022
Merged

Conversation

kylecarbs
Copy link
Member

@kylecarbs kylecarbs requested a review from mafredri November 29, 2022 15:03
@kylecarbs kylecarbs self-assigned this Nov 29, 2022
@kylecarbs
Copy link
Member Author

We should technically add a mutex around reads too, but only tests can access those so I figured it's less important for now.

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed read's aren't as critical, but we could still get races in tests if export and read is happening asynchronously.

@@ -30,10 +31,13 @@ func NewMock() *MockAuditor {
}

type MockAuditor struct {
Mutex sync.Mutex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed by tests or should we make it private?

@kylecarbs kylecarbs enabled auto-merge (squash) November 30, 2022 16:18
@kylecarbs kylecarbs merged commit 2a73362 into main Nov 30, 2022
@kylecarbs kylecarbs deleted the auditrace branch November 30, 2022 16:25
@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants