Skip to content

Commit 6fd287e

Browse files
committed
Fix a deadlock when leader change if enable leader-only option.
Signed-off-by: Yan Zhu <[email protected]>
1 parent ce19516 commit 6fd287e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

client/client.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@ func (o *ovsdbClient) connect(ctx context.Context, reconnect bool) error {
285285
o.logger.V(3).Info("reconnected - restarting monitors")
286286
for dbName, db := range o.databases {
287287
db.monitorsMutex.Lock()
288-
defer db.monitorsMutex.Unlock()
289288

290289
// Purge entire cache if no monitors exist to update dynamically
291290
if len(db.monitors) == 0 {
292291
db.cache.Purge(db.model)
292+
db.monitorsMutex.Unlock()
293293
continue
294294
}
295295

@@ -299,9 +299,11 @@ func (o *ovsdbClient) connect(ctx context.Context, reconnect bool) error {
299299
err := o.monitor(ctx, MonitorCookie{DatabaseName: dbName, ID: id}, true, request)
300300
if err != nil {
301301
o.resetRPCClient()
302+
db.monitorsMutex.Unlock()
302303
return err
303304
}
304305
}
306+
db.monitorsMutex.Unlock()
305307
}
306308
}
307309

0 commit comments

Comments
 (0)