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

Resolve potential deadlocks #438

Merged
merged 4 commits into from
Jun 24, 2021
Merged

Conversation

jschwinger233
Copy link
Member

  1. 上多锁前给锁排序
  2. 如果出现 withNodesLocked + withWorkloadsLocked, 保证先锁节点再锁 workloads
  3. 解锁时候逆序解锁

// force unlock
if err := c.doUnlock(ctx, lock, n); err != nil {
log.Errorf(ctx, "[doUnlockAll] Unlock failed %v", err)
func (c *Calcium) doUnlockAll(ctx context.Context, locks map[string]lock.DistributedLock, order []string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为了兼容性你不如 order string...

@jschwinger233 jschwinger233 changed the title [WIP] Resolve potential deadlocks Resolve potential deadlocks Jun 22, 2021
defer func() { c.doUnlockAll(utils.InheritTracingInfo(ctx, context.Background()), locks) }()
defer func() {
utils.Reverse(ids)
c.doUnlockAll(utils.InheritTracingInfo(ctx, context.Background()), locks, ids...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

background?

defer c.doUnlockAll(utils.InheritTracingInfo(ctx, context.Background()), locks)
defer func() {
utils.Reverse(nodenames)
c.doUnlockAll(utils.InheritTracingInfo(ctx, context.Background()), locks, nodenames...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@CMGS CMGS merged commit 1664108 into projecteru2:master Jun 24, 2021
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

Successfully merging this pull request may close these issues.

2 participants