From 4d42e18c05dd5f7dc0bc8ba8683a346586dc9216 Mon Sep 17 00:00:00 2001 From: Ameya Gawde Date: Wed, 23 Jun 2021 14:59:26 -0700 Subject: [PATCH] vendor: swarmkit to fix deadlock in log broker Signed-off-by: Ameya Gawde --- vendor.conf | 2 +- .../swarmkit/manager/logbroker/subscription.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/vendor.conf b/vendor.conf index b8cb3ae97e..8a05111afa 100644 --- a/vendor.conf +++ b/vendor.conf @@ -142,7 +142,7 @@ github.com/gogo/googleapis 01e0f9cca9b92166042241267ee2 github.com/cilium/ebpf 1c8d4c9ef7759622653a1d319284a44652333b28 # cluster -github.com/docker/swarmkit 17d8d4e4d8bdec33d386e6362d3537fa9493ba00 +github.com/docker/swarmkit c9afb5fd44bb419bae719f400f31671712bcb99e # bump_20.10 github.com/gogo/protobuf 5628607bb4c51c3157aacc3a50f0ab707582b805 # v1.3.1 github.com/golang/protobuf 84668698ea25b64748563aa20726db66a6b8d299 # v1.3.5 github.com/cloudflare/cfssl 5d63dbd981b5c408effbb58c442d54761ff94fbd # 1.3.2 diff --git a/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go b/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go index 883ddce655..45295bb40a 100644 --- a/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go +++ b/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go @@ -204,20 +204,31 @@ func (s *subscription) watch(ch <-chan events.Event) error { } add := func(t *api.Task) { + // this mutex does not have a deferred unlock, because there is work + // we need to do after we release it. s.mu.Lock() - defer s.mu.Unlock() // Un-allocated task. if t.NodeID == "" { s.pendingTasks[t.ID] = struct{}{} + s.mu.Unlock() return } delete(s.pendingTasks, t.ID) if _, ok := s.nodes[t.NodeID]; !ok { s.nodes[t.NodeID] = struct{}{} + + s.mu.Unlock() + + // 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) + return } + + s.mu.Unlock() } for {