Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#44856
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
lance6716 authored and ti-chi-bot committed Jun 21, 2023
1 parent 3368fbf commit b0db3cc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
25 changes: 25 additions & 0 deletions br/pkg/lightning/restore/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,34 @@ func (e *tikvChecksumManager) checksumDB(ctx context.Context, tableInfo *checkpo

func (e *tikvChecksumManager) Checksum(ctx context.Context, tableInfo *checkpoints.TidbTableInfo) (*RemoteChecksum, error) {
tbl := common.UniqueTable(tableInfo.DB, tableInfo.Name)
<<<<<<< HEAD:br/pkg/lightning/restore/checksum.go
physicalTS, logicalTS, err := e.manager.pdClient.GetTS(ctx)
if err != nil {
return nil, errors.Annotate(err, "fetch tso from pd failed")
=======
var (
physicalTS, logicalTS int64
err error
retryTime int
)
physicalTS, logicalTS, err = e.manager.pdClient.GetTS(ctx)
for err != nil {
if !pd.IsLeaderChange(errors.Cause(err)) {
return nil, errors.Annotate(err, "fetch tso from pd failed")
}
retryTime++
if retryTime%60 == 0 {
log.FromContext(ctx).Warn("fetch tso from pd failed and retrying",
zap.Int("retryTime", retryTime),
zap.Error(err))
}
select {
case <-ctx.Done():
err = ctx.Err()
case <-time.After(retryGetTSInterval):
physicalTS, logicalTS, err = e.manager.pdClient.GetTS(ctx)
}
>>>>>>> c6b4e9935a3 (lightning: unwrap the error before call PD function (#44856)):br/pkg/lightning/backend/local/checksum.go
}
ts := oracle.ComposeTS(physicalTS, logicalTS)
if err := e.manager.addOneJob(ctx, tbl, ts); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions br/pkg/lightning/restore/checksum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,14 @@ func (c *testPDClient) currentSafePoint() uint64 {
}

func (c *testPDClient) GetTS(ctx context.Context) (int64, int64, error) {
<<<<<<< HEAD:br/pkg/lightning/restore/checksum_test.go
physicalTS := time.Now().UnixNano() / 1e6
=======
physicalTS := time.Now().UnixMilli()
if c.leaderChanging && physicalTS%2 == 0 {
return 0, 0, errors.WithStack(errs.ErrClientTSOStreamClosed)
}
>>>>>>> c6b4e9935a3 (lightning: unwrap the error before call PD function (#44856)):br/pkg/lightning/backend/local/checksum_test.go
logicalTS := oracle.ExtractLogical(c.logicalTSCounter.Inc())
return physicalTS, logicalTS, nil
}
Expand Down

0 comments on commit b0db3cc

Please sign in to comment.