diff --git a/libnetwork/endpoint_cnt.go b/libnetwork/endpoint_cnt.go index c63d06abe0..7b7527426d 100644 --- a/libnetwork/endpoint_cnt.go +++ b/libnetwork/endpoint_cnt.go @@ -138,6 +138,15 @@ func (ec *endpointCnt) setCnt(cnt uint64) error { } func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error { + store := ec.n.getController().getStore(ec.DataScope()) + if store == nil { + return fmt.Errorf("store not found for scope %s", ec.DataScope()) + } + + tmp := &endpointCnt{n: ec.n} + if err := store.GetObject(datastore.Key(ec.Key()...), tmp); err != nil { + return err + } retry: ec.Lock() if inc { @@ -149,11 +158,6 @@ retry: } ec.Unlock() - store := ec.n.getController().getStore(ec.DataScope()) - if store == nil { - return fmt.Errorf("store not found for scope %s", ec.DataScope()) - } - if err := ec.n.getController().updateToStore(ec); err != nil { if err == datastore.ErrKeyModified { if err := store.GetObject(datastore.Key(ec.Key()...), ec); err != nil { diff --git a/libnetwork/store.go b/libnetwork/store.go index 1a897bfe01..da7ac1dea6 100644 --- a/libnetwork/store.go +++ b/libnetwork/store.go @@ -256,6 +256,7 @@ retry: if err := cs.GetObject(datastore.Key(kvObject.Key()...), kvObject); err != nil { return fmt.Errorf("could not update the kvobject to latest when trying to delete: %v", err) } + logrus.Errorf("Error (%v) deleting object %v, retrying....", err, kvObject.Key()) goto retry } return err