From 5b04088775df0ed076790cb05826980b20b81acc Mon Sep 17 00:00:00 2001 From: nolouch Date: Wed, 26 Dec 2018 12:01:35 +0800 Subject: [PATCH] server/leader: use the compact revision to watch leader Signed-off-by: nolouch --- pkg/integration_test/leader_watch_test.go | 2 +- server/leader.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/integration_test/leader_watch_test.go b/pkg/integration_test/leader_watch_test.go index 350a4f12477..9c88c814de9 100644 --- a/pkg/integration_test/leader_watch_test.go +++ b/pkg/integration_test/leader_watch_test.go @@ -25,7 +25,7 @@ import ( func (s *integrationTestSuite) TestWatcher(c *C) { c.Parallel() - cluster, err := newTestCluster(1) + cluster, err := newTestCluster(1, func(conf *server.Config) { conf.AutoCompactionRetention = "1s" }) c.Assert(err, IsNil) defer cluster.Destroy() diff --git a/server/leader.go b/server/leader.go index 2b4f8a98643..7fc58ee2e25 100644 --- a/server/leader.go +++ b/server/leader.go @@ -314,8 +314,8 @@ func (s *Server) watchLeader(leader *pdpb.Member, revision int64) { for wresp := range rch { // meet compacted error, use current revision. if wresp.CompactRevision != 0 { - log.Warnf("required revision %d has been compacted, use current revision", revision) - revision = 0 + log.Warnf("required revision %d has been compacted, use the compact revision %d", revision, wresp.CompactRevision) + revision = wresp.CompactRevision break } if wresp.Canceled {