Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <[email protected]>
  • Loading branch information
CabinfeverB committed Dec 5, 2023
1 parent 013fbce commit 0891cf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/pd_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ func (c *pdServiceClient) GetClientConn() *grpc.ClientConn {

// NeedRetry implements ServiceClient.
func (c *pdServiceClient) NeedRetry(pdErr *pdpb.Error, err error) bool {
return !c.IsLeader()
if c.IsLeader() {
return false
}
return !(err == nil && pdErr == nil)
}

type errFn func(pdErr *pdpb.Error) bool
Expand Down
5 changes: 5 additions & 0 deletions client/pd_service_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ func (suite *serviceClientTestSuite) SetupSuite() {
}

func (suite *serviceClientTestSuite) TearDownTest() {
suite.leaderServer.server.resetCount()
suite.followerServer.server.resetCount()
}

func (suite *serviceClientTestSuite) TearDownSuite() {
suite.leaderServer.grpcServer.GracefulStop()
suite.followerServer.grpcServer.GracefulStop()
suite.clean()
Expand Down

0 comments on commit 0891cf1

Please sign in to comment.