Skip to content

Commit

Permalink
Seeds math/rand (#98)
Browse files Browse the repository at this point in the history
* Seeds math/rand

For background on why this is necessary see:

m-lab/dev-tracker#689

* Changes 'unexpected' to 'unintended' in comment
  • Loading branch information
nkinkade committed Oct 29, 2021
1 parent 35f4dc9 commit 174abf0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"log"
"math/rand"
"os"
"os/signal"
"path"
Expand Down Expand Up @@ -182,6 +183,13 @@ M-Lab uniform naming conventions.
// ListenForever loops are still running.
wg := sync.WaitGroup{}

// Seeds math/rand with a unique seed. Without this, rand will return a
// predictable pattern of "random" numbers, causing the "memoryless" package
// to potentially schedule runs of pusher in unintended ways. For more
// background, see this issue:
// https://github.com/m-lab/dev-tracker/issues/689
rand.Seed(time.Now().UnixNano())

// Set up pushing for every datatype.
for _, datatype := range datatypes {
// Set up the upload system.
Expand Down

0 comments on commit 174abf0

Please sign in to comment.