Skip to content

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

@xiaoxubeii

Description

@xiaoxubeii

Ⅰ. 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions