diff --git a/lightning/restore/checksum.go b/lightning/restore/checksum.go index 2dc802ee9bc4b..918ba182c242a 100644 --- a/lightning/restore/checksum.go +++ b/lightning/restore/checksum.go @@ -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), } } diff --git a/lightning/restore/checksum_test.go b/lightning/restore/checksum_test.go index dfe450bddd151..c3b78cfb9bbe4 100644 --- a/lightning/restore/checksum_test.go +++ b/lightning/restore/checksum_test.go @@ -5,6 +5,7 @@ import ( "database/sql" "fmt" "sort" + "strings" "sync" "sync/atomic" "time" @@ -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() @@ -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) }