Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] PR #2319 ctrd/container_lock.go TrylockWithRetry is not FIFO #2335

Closed
xiaoxubeii opened this issue Oct 19, 2018 · 2 comments
Closed

Comments

@xiaoxubeii
Copy link
Contributor

Ⅰ. Issue Description

In #2319 ctrd/container_lock.go:

func (l *containerLock) TrylockWithRetry(ctx context.Context, id string) bool {
	var retry = 32


	for {
		ok := l.Trylock(id)
		if ok {
			return true
		}


		// sleep random duration by retry
		select {
		case <-time.After(time.Millisecond * time.Duration(rand.Intn(retry))):
			if retry < 2048 {
				retry = retry << 1
			}
			continue
		case <-ctx.Done():
			return false
		}
	}
}

The retry mechanism is not FIFO, so the probability of getting a lock is dependent on the retry intervals. Is this acceptable?

Ⅱ. Describe what happened

Ⅲ. Describe what you expected to happen

Ⅳ. How to reproduce it (as minimally and precisely as possible)

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

  • pouch version (use pouch version):
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:
@fuweid
Copy link
Contributor

fuweid commented Oct 19, 2018

basically, we don't consider it as normal mode, as you mentioned. It's like starvation mode. I think it's ok here.

@xiaoxubeii
Copy link
Contributor Author

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants