Skip to content

Commit

Permalink
Fix deadlock in Consul RTT.
Browse files Browse the repository at this point in the history
- consul/rtt.go:388: s.getDatacentersByDistance().  Acquires RLock()
- consul/rtt.go:341: sortDatacentersByDistance() RLock still held.
- consul/rtt.go:282: getDatacenterDistance() RLock still held.
- consul/rtt.go:268: getNodesForDatacenter(). Attempts to reacquire RLock(), hangs indefinitely.
  • Loading branch information
sean- committed Jun 20, 2016
1 parent af30e17 commit c3e54b7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions consul/rtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,11 @@ func getDatacenterMaps(s serfer, dcs []string) []structs.DatacenterMap {
// other things being equal (or if coordinates are disabled).
func (s *Server) getDatacentersByDistance() ([]string, error) {
s.remoteLock.RLock()
defer s.remoteLock.RUnlock()

var dcs []string
dcs := make([]string, 0, len(s.remoteConsuls))
for dc := range s.remoteConsuls {
dcs = append(dcs, dc)
}
s.remoteLock.RUnlock()

// Sort by name first, since the coordinate sort is stable.
sort.Strings(dcs)
Expand Down

0 comments on commit c3e54b7

Please sign in to comment.