nsqio / go-nsq

The official Go package for NSQ
MIT License
2.59k stars 444 forks source link

*: fix github actions #330

Closed mreiferson closed 3 years ago

ploxiln commented 3 years ago
--- FAIL: TestFullJitterBackoff (0.00s)
panic: invalid argument to Intn [recovered]
    panic: invalid argument to Intn

goroutine 9 [running]:
testing.tRunner.func1.2({0x82fcd00, 0x83aa4f8})
    /usr/local/go/src/testing/testing.go:1209 +0x2ab
testing.tRunner.func1(0xa0014a0)
    /usr/local/go/src/testing/testing.go:1212 +0x27d
panic({0x82fcd00, 0x83aa4f8})
    /usr/local/go/src/runtime/panic.go:1038 +0x1c5
math/rand.(*Rand).Intn(0xa00ec00, 0xdcd65000)
    /usr/local/go/src/math/rand/rand.go:168 +0x7d
github.com/nsqio/go-nsq.(*FullJitterStrategy).Calculate(0xa1061f8, 0x3)
    /__w/go-nsq/go-nsq/go/src/github.com/nsqio/go-nsq/config.go:75 +0xac
    backoffDuration := s.cfg.BackoffMultiplier *
        time.Duration(math.Pow(2, float64(attempt)))
    return time.Duration(s.rng.Intn(int(backoffDuration)))

I think int(backoffDuration) ended up being 0 ?

ploxiln commented 3 years ago

... oh, wraparound, that would also do it

mreiferson commented 3 years ago

I'm not sure how this ever passed on 386?

mreiferson commented 3 years ago

well, that was fun

ploxiln commented 3 years ago

nice little fix for 32-bit architectures!