-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Closed
Copy link
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
What version of Go are you using (go version)?
1.17.1
Does this issue reproduce with the latest release?
Can't say, don't know how to reproduce.
What operating system and processor architecture are you using (go env)?
It was built for amd64 and linux, and running in alpine (docker in k8s).
What did you do?
I was pretty usually using math.rand, with the following code:
var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
const charset = "abcdefghijklmnopqrstuvwxyz"
func RandomString(length int) string {
b := make([]byte, length)
charsetLen := len(charset)
for i := range b {
b[i] = charset[seededRand.Intn(charsetLen)]
}
return string(b)
}
What did you expect to see?
Random sting, as I usually did.
What did you see instead?
I had 3 instances of this service running. After the long time of running as expected (~1.5 months) one service started consistently returning "aaaaaaaaaa" for RandomString(10) (other 2 continued working as expected).
This was a very weird situation, would someone know what might have happened, is it fixed in some new go version, or how to mitigate? I'm thinking of mitigating by changing to a new random seed if I recognize the random returning always 0....
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.