Skip to content

vendor: swarmkit to fix deadlock in log broker.#42537

Merged
thaJeztah merged 1 commit into
moby:masterfrom
dperny:vendor-swarmkit-fix-logbroker-deadlock
Jun 21, 2021
Merged

vendor: swarmkit to fix deadlock in log broker.#42537
thaJeztah merged 1 commit into
moby:masterfrom
dperny:vendor-swarmkit-fix-logbroker-deadlock

Conversation

@dperny

@dperny dperny commented Jun 18, 2021

Copy link
Copy Markdown
Contributor

Revendors swarmkit to fix a deadlock in the log broker. Closes #42314.

Revendors swarmkit to fix a bug that could result in a mutex deadlock in
the logbroker.

Signed-off-by: Drew Erny <[email protected]>

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SGTM

// if we try to call Publish before we release the lock, we can end
// up in a situation where the receiver is trying to acquire a read
// lock on it. it's hard to explain.
s.changed.Publish(s)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

reading from my phone, but should we perhaps have a "Publish()" that does not try to acquire a lock for this purpose, or is that lock happening elsewhere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or to keep things safer we can do something like

var publish bool
s.mu.Lock()
defer func() {
    s.mu.Unlock()
    if publish {
        s.changed.Publish(s)
    }
}()

@thaJeztah

Copy link
Copy Markdown
Member

FWIW; if we want to backport this, we'd need a 20.10 branch in swarmkit (not sure if we want)

@cpuguy83 cpuguy83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks fine to me.
I like to keep unlocks in a defer where possible for safety sake but code looks OK as is.

// if we try to call Publish before we release the lock, we can end
// up in a situation where the receiver is trying to acquire a read
// lock on it. it's hard to explain.
s.changed.Publish(s)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or to keep things safer we can do something like

var publish bool
s.mu.Lock()
defer func() {
    s.mu.Unlock()
    if publish {
        s.changed.Publish(s)
    }
}()

@thaJeztah

Copy link
Copy Markdown
Member

Let's merge this one; @dperny perhaps you could look at the suggestions above to address those in a follow-up swarmkit revenuer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analysis of docker swarm "dispatcher is stopped"

3 participants