Skip to content

Commit

Permalink
fix service gc ttl again (pingcap#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
glorv authored Nov 11, 2020
1 parent 0e8cef2 commit 963829f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 2 additions & 4 deletions lightning/restore/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,8 @@ type tikvChecksumManager struct {
// newTiKVChecksumManager return a new tikv checksum manager
func newTiKVChecksumManager(client kv.Client, pdClient pd.Client) *tikvChecksumManager {
return &tikvChecksumManager{
client: client,
manager: gcTTLManager{
pdClient: pdClient,
},
client: client,
manager: newGCTTLManager(pdClient),
}
}

Expand Down
9 changes: 5 additions & 4 deletions lightning/restore/checksum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"sort"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -229,8 +230,8 @@ func (c *testPDClient) currentSafePoint() uint64 {
}

func (c *testPDClient) UpdateServiceGCSafePoint(ctx context.Context, serviceID string, ttl int64, safePoint uint64) (uint64, error) {
if serviceID == "" {
panic("service ID must not be empty")
if !strings.HasPrefix(serviceID, "lightning") {
panic("service ID must start with 'lightning'")
}
atomic.AddInt32(&c.count, 1)
c.Lock()
Expand Down Expand Up @@ -312,9 +313,9 @@ func (s *checksumSuite) TestGcTTLManagerMulti(c *C) {
func (s *checksumSuite) TestPdServiceID(c *C) {
pdCli := &testPDClient{}
gcTTLManager1 := newGCTTLManager(pdCli)
c.Assert(gcTTLManager1.serviceID != "", IsTrue)
c.Assert(gcTTLManager1.serviceID, Matches, "lightning-.*")
gcTTLManager2 := newGCTTLManager(pdCli)
c.Assert(gcTTLManager2.serviceID != "", IsTrue)
c.Assert(gcTTLManager2.serviceID, Matches, "lightning-.*")

c.Assert(gcTTLManager1.serviceID != gcTTLManager2.serviceID, IsTrue)
}
Expand Down

0 comments on commit 963829f

Please sign in to comment.