Skip to content
This repository has been archived by the owner on Mar 2, 2023. It is now read-only.

blocking key deadlock problem #4

Closed
JasonHu520 opened this issue Feb 15, 2022 · 0 comments
Closed

blocking key deadlock problem #4

JasonHu520 opened this issue Feb 15, 2022 · 0 comments

Comments

@JasonHu520
Copy link
Collaborator

JasonHu520 commented Feb 15, 2022

问题场景:

if kl == nil {
		l.lock.RUnlock()
		l.lock.Lock()
		kl = newBlocker(l.limit)
		l.keyMap[key] = kl
		kl.addRef()
		l.lock.Unlock()
  1. In a concurrent scenario, when aquire a single key, the obtained key maybe nil and no secondary check is performed, which may result in the same key being overwritten.
if kl.loadRef() < 0 {
			l.lock.Unlock()
			panic("internal error: refs < 0")
		}
		if kl.loadRef() == 0 {
			delete(l.keyMap, key)
		}
		kls = append(kls, kl)
	}
	for _, kl := range kls {
		kl.release()
	}
  1. When the key is released, there is a problem with the reference count judgment, resulting in the repeated release of the key's lock
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant