taskq icon indicating copy to clipboard operation
taskq copied to clipboard

Prevent exponential backoff delay from overflowing

Open skateinmars opened this issue 2 years ago • 1 comments

Because of the bit shifting used in the exponential backoff computation, an overflow can happen given some specific values for min/max backoff.

Here is a snippet to show the current and fixed behavior: https://go.dev/play/p/V2tno9piKly

This PR fixes it without trying to change the "normal" behavior by simply using the max backoff value when an overflow happens.

skateinmars avatar Oct 16 '23 10:10 skateinmars

@skateinmars I think you can move the code from https://go.dev/play/p/V2tno9piKlk to a test https://github.com/vmihailenco/taskq/blob/v3/consumer_test.go

lilien1010 avatar Apr 28 '25 03:04 lilien1010