Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightning: auto resume from recoverable error #33510

Merged
merged 7 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions br/pkg/lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,11 +972,14 @@ func (rc *Controller) saveStatusCheckpoint(ctx context.Context, tableName string
switch {
sleepymole marked this conversation as resolved.
Show resolved Hide resolved
case err == nil:
break
case !common.IsContextCanceledError(err):
case utils.IsRetryableError(err), utils.MessageIsRetryableStorageError(err.Error()), common.IsContextCanceledError(err):
// recoverable error, should not be recorded in checkpoint
// which will prevent lightning from automatically recovering
return nil
default:
// unrecoverable error
merger.SetInvalid()
rc.errorSummaries.record(tableName, err, statusIfSucceed)
default:
return nil
}

if engineID == checkpoints.WholeTableEngineID {
Expand Down
13 changes: 12 additions & 1 deletion br/pkg/lightning/restore/table_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"net"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -989,8 +990,18 @@ func (s *tableRestoreSuite) TestSaveStatusCheckpoint() {
rc.checkpointsWg.Add(1)
go rc.listenCheckpointUpdates()

rc.errorSummaries = makeErrorSummaries(log.L())

err := rc.saveStatusCheckpoint(context.Background(), common.UniqueTable("test", "tbl"), indexEngineID, errors.New("connection refused"), checkpoints.CheckpointStatusImported)
require.NoError(s.T(), err)
require.Equal(s.T(), 0, len(rc.errorSummaries.summary))

err = rc.saveStatusCheckpoint(context.Background(), common.UniqueTable("test", "tbl"), indexEngineID, &net.DNSError{IsTimeout: true}, checkpoints.CheckpointStatusImported)
require.NoError(s.T(), err)
require.Equal(s.T(), 0, len(rc.errorSummaries.summary))

start := time.Now()
err := rc.saveStatusCheckpoint(context.Background(), common.UniqueTable("test", "tbl"), indexEngineID, nil, checkpoints.CheckpointStatusImported)
err = rc.saveStatusCheckpoint(context.Background(), common.UniqueTable("test", "tbl"), indexEngineID, nil, checkpoints.CheckpointStatusImported)
require.NoError(s.T(), err)
elapsed := time.Since(start)
require.GreaterOrEqual(s.T(), elapsed, time.Millisecond*100)
Expand Down