go-redsync/redsync

History related to default `tries` value

Closed this issue · 3 comments

tries: 32,

Currently, default tries value is 32.

I doubt 32 is proper default value.

I am wondering that there is any history related default tries value.

If there's no reason, how about changing default tries value?

I believe users don't expect 32 retries by default.

I think 32 is chosen because maxRetryDelayMilliSec * 32 is equal to expiry: 8 * time.Second which is the default.

const (
	minRetryDelayMilliSec = 50
	maxRetryDelayMilliSec = 250
)

func (r *Redsync) NewMutex(name string, options ...Option) *Mutex {
	m := &Mutex{
		name:   name,
		expiry: 8 * time.Second,
		tries:  32,

I assume 32 is needed to be able to acquire a lock after default 8 seconds.

@VadimKulagin thank you for the answer.

What I try to understand is below.

When some other client failed to unlock mutex with default configurations, it won't be able to get a lock because expiry is 8 * time.Second and delay function randomize delays from 50 to 250 msecs.

I doubt current default configuration has proper values.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.