Closed calvinxiao closed 3 years ago
@dim this data race is not critical but it's breaking CI with go test -race
, please take a look.
Thanks for this, much appreciated, a few comments ^^
I think redislock.Options
should be created every time when using Obtain
function, I found in our codes that redislock.Options
is a global variable, which is wrong.
@dim , the root problem is when redislock.Options
being used as a global variable, I think it's better if we can have a Clone
method for RetryStrategy
, this makes sure that cnt
is always 0 when Obtain
executes. I think this will be better than what this PR does.
Or we can update the doc and example to show how options should be used.
What do you think?
I prefer the solution in #32, then we don't need all the atomic workaround.
I prefer the solution in #32, then we don't need all the atomic workaround.
As said before, I prefer not to break the API. I think using atomics is fine.
When using linear and exponential backoff retry strategy, there is data race when increasing the counter
cnt
.