Skip to content

extproc: fixes race condition with RNG #417

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 4 commits into from
Feb 24, 2025
Merged

extproc: fixes race condition with RNG #417

merged 4 commits into from
Feb 24, 2025

Conversation

mathetake
Copy link
Member

Commit Message

Previously, router instance shared the rng among multiple goroutines which is not a thread safe. This fixes it by having a goroutine local RNG.

Related Issues/PRs (if applicable)

Contributes to #53

@mathetake mathetake marked this pull request as ready for review February 24, 2025 22:43
@mathetake mathetake requested a review from a team as a code owner February 24, 2025 22:43
Signed-off-by: Takeshi Yoneda <[email protected]>
Copy link
Contributor

@aabchoo aabchoo left a comment

Choose a reason for hiding this comment

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

lgtm!

}()
}
wg.Wait()
require.Greater(t, bar.Load(), foo.Load())
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a case where bar.load() + foo.load() === 1000?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's implicitly ensured via wg.Wait but good point!

Signed-off-by: Takeshi Yoneda <[email protected]>
@mathetake mathetake merged commit ab793cf into main Feb 24, 2025
15 checks passed
@mathetake mathetake deleted the routerconcurrency branch February 24, 2025 23:29
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.

2 participants