Skip to content

Commit daf7d4f

Browse files
authored
finish the leave process if broadcasting leave timeout (#640)
* finish the leave process if broadcasting leave timeout * Log broadcast timeout as WARN and finish the Leave process. * increase timeout
1 parent d223c69 commit daf7d4f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

serf/coalesce_member_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestMemberEventCoalesce_TagUpdate(t *testing.T) {
134134
Members: []Member{Member{Name: "foo", Tags: map[string]string{"role": "foo"}}},
135135
}
136136

137-
time.Sleep(10 * time.Millisecond)
137+
time.Sleep(30 * time.Millisecond)
138138

139139
select {
140140
case e := <-outCh:

serf/serf.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/base64"
66
"encoding/json"
7-
"errors"
87
"fmt"
98
"io/ioutil"
109
"log"
@@ -685,6 +684,7 @@ func (s *Serf) broadcastJoin(ltime LamportTime) error {
685684

686685
// Leave gracefully exits the cluster. It is safe to call this multiple
687686
// times.
687+
// If the Leave broadcast timeout, Leave() will try to finish the sequence as best effort.
688688
func (s *Serf) Leave() error {
689689
// Check the current state
690690
s.stateLock.Lock()
@@ -727,14 +727,14 @@ func (s *Serf) Leave() error {
727727
select {
728728
case <-notifyCh:
729729
case <-time.After(s.config.BroadcastTimeout):
730-
return errors.New("timeout while waiting for graceful leave")
730+
s.logger.Printf("[WARN] serf: timeout while waiting for graceful leave")
731731
}
732732
}
733733

734734
// Attempt the memberlist leave
735735
err := s.memberlist.Leave(s.config.BroadcastTimeout)
736736
if err != nil {
737-
return err
737+
s.logger.Printf("[WARN] serf: timeout waiting for leave broadcast: %s", err.Error())
738738
}
739739

740740
// Wait for the leave to propagate through the cluster. The broadcast

0 commit comments

Comments
 (0)