mirror of
https://github.com/status-im/consul.git
synced 2025-02-02 17:03:31 +00:00
Fix deadlock in Consul RTT.
- 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.
This commit is contained in:
parent
af30e17dcd
commit
c3e54b79fd
@ -386,12 +386,11 @@ func getDatacenterMaps(s serfer, dcs []string) []structs.DatacenterMap {
|
|||||||
// other things being equal (or if coordinates are disabled).
|
// other things being equal (or if coordinates are disabled).
|
||||||
func (s *Server) getDatacentersByDistance() ([]string, error) {
|
func (s *Server) getDatacentersByDistance() ([]string, error) {
|
||||||
s.remoteLock.RLock()
|
s.remoteLock.RLock()
|
||||||
defer s.remoteLock.RUnlock()
|
dcs := make([]string, 0, len(s.remoteConsuls))
|
||||||
|
|
||||||
var dcs []string
|
|
||||||
for dc := range s.remoteConsuls {
|
for dc := range s.remoteConsuls {
|
||||||
dcs = append(dcs, dc)
|
dcs = append(dcs, dc)
|
||||||
}
|
}
|
||||||
|
s.remoteLock.RUnlock()
|
||||||
|
|
||||||
// Sort by name first, since the coordinate sort is stable.
|
// Sort by name first, since the coordinate sort is stable.
|
||||||
sort.Strings(dcs)
|
sort.Strings(dcs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user