Skip to content

Commit f59a11b

Browse files
authored
Merge pull request #390 from halfcrazy/fix-deadlock
Fix a deadlock when leader change if enable leader-only option.
2 parents 2ac1d59 + 6fd287e commit f59a11b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

client/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ func (o *ovsdbClient) connect(ctx context.Context, reconnect bool) error {
278278
o.logger.V(3).Info("reconnected - restarting monitors")
279279
for dbName, db := range o.databases {
280280
db.monitorsMutex.Lock()
281-
defer db.monitorsMutex.Unlock()
282281

283282
// Purge entire cache if no monitors exist to update dynamically
284283
if len(db.monitors) == 0 {
285284
db.cache.Purge(db.model)
285+
db.monitorsMutex.Unlock()
286286
continue
287287
}
288288

@@ -292,9 +292,11 @@ func (o *ovsdbClient) connect(ctx context.Context, reconnect bool) error {
292292
err := o.monitor(ctx, MonitorCookie{DatabaseName: dbName, ID: id}, true, request)
293293
if err != nil {
294294
o.resetRPCClient()
295+
db.monitorsMutex.Unlock()
295296
return err
296297
}
297298
}
299+
db.monitorsMutex.Unlock()
298300
}
299301
}
300302

0 commit comments

Comments
 (0)