Browse Source

etcdserver: discard messages if sender reaches max serving

It is the correct thing to do to ensure that the communication is full
of out-of-date messages.

It results in that integration testing is very easy to throw MsgProp away,
and makes client wait until 5 min timeout. Sync interval and heartbeat are
increased to alleviate the traffic.
Yicheng Qin 11 years ago
parent
commit
c3b0de943c
2 changed files with 7 additions and 5 deletions
  1. 5 3
      etcdserver/sender.go
  2. 2 2
      integration/cluster_test.go

+ 5 - 3
etcdserver/sender.go

@@ -125,9 +125,11 @@ func newSender(u string, cid types.ID, c *http.Client, fs *stats.FollowerStats)
 }
 
 func (s *sender) send(data []byte) {
-	// TODO: we cannot afford the miss of MsgProp, so we wait for some handler
-	// to take the data
-	s.q <- data
+	select {
+	case s.q <- data:
+	default:
+		log.Printf("sender: reach the maximal serving to %s", s.u)
+	}
 }
 
 func (s *sender) stop() {

+ 2 - 2
integration/cluster_test.go

@@ -36,7 +36,7 @@ import (
 )
 
 const (
-	tickDuration = 5 * time.Millisecond
+	tickDuration = 10 * time.Millisecond
 	clusterName  = "etcd"
 )
 
@@ -181,7 +181,7 @@ func (m *member) Launch(t *testing.T) {
 		t.Fatalf("failed to initialize the etcd server: %v", err)
 	}
 	m.s.Ticker = time.Tick(tickDuration)
-	m.s.SyncTicker = time.Tick(tickDuration)
+	m.s.SyncTicker = time.Tick(10 * tickDuration)
 	m.s.Start()
 
 	for _, ln := range m.PeerListeners {