Permalink
Browse files

Fixing issue with aliveMsg replay

  • Loading branch information...
armon committed Nov 14, 2014
1 parent 9dc0511 commit 63ef41a08f845463ae968b58ca4927666ccc1f4e
Showing with 21 additions and 4 deletions.
  1. +3 −4 state.go
  2. +18 −0 state_test.go
View
@@ -3,12 +3,13 @@ package memberlist
import (
"bytes"
"fmt"
- "github.com/armon/go-metrics"
"math"
"math/rand"
"net"
"sync/atomic"
"time"
+
+ "github.com/armon/go-metrics"
)
type nodeStateType int
@@ -277,6 +278,7 @@ func (m *Memberlist) resetNodes() {
// Deregister the dead nodes
for i := deadIdx; i < len(m.nodes); i++ {
+ delete(m.nodeMap, m.nodes[i].Name)
m.nodes[i] = nil
}
@@ -855,9 +857,6 @@ func (m *Memberlist) deadNode(d *dead) {
state.State = stateDead
state.StateChange = time.Now()
- // Remove from the node map
- delete(m.nodeMap, state.Name)
-
// Notify of death
if m.config.Events != nil {
m.config.Events.NotifyLeave(&state.Node)
View
@@ -712,6 +712,24 @@ func TestMemberList_DeadNode_OldDead(t *testing.T) {
}
}
+func TestMemberList_DeadNode_AliveReplay(t *testing.T) {
+ m := GetMemberlist(t)
+ a := alive{Node: "test", Addr: []byte{127, 0, 0, 1}, Incarnation: 10}
+ m.aliveNode(&a, nil, false)
+
+ d := dead{Node: "test", Incarnation: 10}
+ m.deadNode(&d)
+
+ // Replay alive at same incarnation
+ m.aliveNode(&a, nil, false)
+
+ // Should remain dead
+ state, ok := m.nodeMap["test"]
+ if ok && state.State != stateDead {
+ t.Fatalf("Bad state")

This comment has been minimized.

Show comment
Hide comment
@amadeus

amadeus Nov 14, 2014

What kind of weird camelCase is this?

@amadeus

amadeus Nov 14, 2014

What kind of weird camelCase is this?

This comment has been minimized.

Show comment
Hide comment
@armon

armon Nov 14, 2014

Member

:|

+ }
+}
+
func TestMemberList_DeadNode_Refute(t *testing.T) {
m := GetMemberlist(t)
a := alive{Node: m.config.Name, Addr: []byte{127, 0, 0, 1}, Incarnation: 1}

1 comment on commit 63ef41a

@i0rek

This comment has been minimized.

Show comment
Hide comment

i0rek commented on 63ef41a Nov 14, 2014

😍

Please sign in to comment.