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

Incorrect use of rand #6134

Closed
HunDunDM opened this issue Mar 9, 2023 · 0 comments · Fixed by #6207
Closed

Incorrect use of rand #6134

HunDunDM opened this issue Mar 9, 2023 · 0 comments · Fixed by #6207
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@HunDunDM
Copy link
Member

HunDunDM commented Mar 9, 2023

Enhancement Task

  • Many packages use the following init functions, which cannot achieve the effect of setting seeds. The Rand object from New is unused.
func init() {
	rand.New(rand.NewSource(time.Now().UnixNano()))
}
  • The global rand function is thread-safe at the cost of having a global write lock. This may cause unexpected performance problems in some places.
@HunDunDM HunDunDM added the type/enhancement The issue or PR belongs to an enhancement. label Mar 9, 2023
ti-chi-bot added a commit that referenced this issue Mar 22, 2023
close #6134

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant