-
-
Notifications
You must be signed in to change notification settings - Fork 201
Closed
Labels
Description
Observed behaviour
Apologizes for not testing this, but rather I am simply reporting it as I've noticed this while exploring the codebase. It seems that there might be a deadlocking situation happening in the websocket service.
go-feature-flag/cmd/relayproxy/service/websocket.go
Lines 42 to 51 in 7eeeaf1
| func (w *websocketServiceImpl) BroadcastFlagChanges(diff notifier.DiffCache) { | |
| w.mutex.RLock() | |
| defer w.mutex.RUnlock() | |
| for c := range w.clients { | |
| err := c.WriteJSON(diff) | |
| if err != nil { | |
| w.Deregister(c) | |
| } | |
| } | |
| } |
In the BroadcastFlagChanges we are RLock-ing the mutex, but if writing the message to a client fails, we will Deregister them, and the Deregister is getting the Lock:
go-feature-flag/cmd/relayproxy/service/websocket.go
Lines 61 to 65 in 7eeeaf1
| func (w *websocketServiceImpl) Deregister(c WebsocketConn) { | |
| w.mutex.Lock() | |
| defer w.mutex.Unlock() | |
| delete(w.clients, c) | |
| } |
As you can't upgrade the RWLock, this can block the whole server.
Expected Behavior
No deadlock to happen.
Steps to reproduce
No response
Reactions are currently unavailable