Skip to content

Commit

Permalink
cherry pick #3138 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
MyonKeminta authored and ti-srebot committed Nov 3, 2020
1 parent f9ce6a0 commit b2135a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"context"
"fmt"
"io"
"math"
"strconv"
"sync/atomic"
"time"
Expand Down Expand Up @@ -807,6 +808,9 @@ func (s *Server) UpdateServiceGCSafePoint(ctx context.Context, request *pdpb.Upd
ExpiredAt: now.Unix() + request.TTL,
SafePoint: request.SafePoint,
}
if request.TTL == math.MaxInt64 {
ssp.ExpiredAt = math.MaxInt64
}
if err := s.storage.SaveServiceGCSafePoint(ssp); err != nil {
return nil, err
}
Expand Down
11 changes: 10 additions & 1 deletion tests/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,17 @@ func (s *testClientSuite) TestUpdateServiceGCSafePoint(c *C) {
minSsp, err = s.srv.GetStorage().LoadMinServiceGCSafePoint(time.Now())
c.Assert(err, IsNil)
c.Assert(minSsp.ServiceID, Equals, "c")
c.Assert(oldMinSsp.SafePoint, Equals, uint64(3))
c.Assert(minSsp.ExpiredAt, Less, oldMinSsp.ExpiredAt)

// TTL can be infinite
min, err = s.client.UpdateServiceGCSafePoint(context.Background(),
"c", math.MaxInt64, 3)
c.Assert(err, IsNil)
c.Assert(min, Equals, uint64(3))
minSsp, err = s.srv.GetStorage().LoadMinServiceGCSafePoint(time.Now())
c.Assert(err, IsNil)
c.Assert(minSsp.ServiceID, Equals, "c")
c.Assert(minSsp.ExpiredAt, Equals, int64(math.MaxInt64))
}

func (s *testClientSuite) TestScatterRegion(c *C) {
Expand Down

0 comments on commit b2135a6

Please sign in to comment.