Skip to content

Commit

Permalink
Fix a deadlock when leader change if enable leader-only option.
Browse files Browse the repository at this point in the history
  • Loading branch information
halfcrazy committed Sep 27, 2024
1 parent ce19516 commit d584440
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ func (o *ovsdbClient) connect(ctx context.Context, reconnect bool) error {
o.logger.V(3).Info("reconnected - restarting monitors")
for dbName, db := range o.databases {
db.monitorsMutex.Lock()
defer db.monitorsMutex.Unlock()

// Purge entire cache if no monitors exist to update dynamically
if len(db.monitors) == 0 {
db.cache.Purge(db.model)
db.monitorsMutex.Unlock()
continue
}

Expand All @@ -299,9 +299,11 @@ func (o *ovsdbClient) connect(ctx context.Context, reconnect bool) error {
err := o.monitor(ctx, MonitorCookie{DatabaseName: dbName, ID: id}, true, request)
if err != nil {
o.resetRPCClient()
db.monitorsMutex.Unlock()
return err
}
}
db.monitorsMutex.Unlock()
}
}

Expand Down

0 comments on commit d584440

Please sign in to comment.