Browse Source

server: prevent blocking

nolouch 7 years ago
parent
commit
f3f6427586
2 changed files with 5 additions and 1 deletions
  1. 1 0
      clientv3/integration/leasing_test.go
  2. 4 1
      etcdserver/server.go

+ 1 - 0
clientv3/integration/leasing_test.go

@@ -1790,6 +1790,7 @@ func TestLeasingTxnOwnerPutBranch(t *testing.T) {
 	defer testutil.AfterTest(t)
 	clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
 	defer clus.Terminate(t)
+
 	lkv, closeLKV, err := leasing.NewKV(clus.Client(0), "foo/")
 	testutil.AssertNil(t, err)
 	defer closeLKV()

+ 4 - 1
etcdserver/server.go

@@ -942,7 +942,10 @@ func (s *EtcdServer) run() {
 				}
 			}
 			if newLeader {
-				s.leaderChanged <- struct{}{}
+				select {
+				case s.leaderChanged <- struct{}{}:
+				default:
+				}
 			}
 			// TODO: remove the nil checking
 			// current test utility does not provide the stats