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 5 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
4 changes: 4 additions & 0 deletions br/pkg/lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,10 @@ 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 utils.IsRetryableError(err), utils.MessageIsRetryableStorageError(err.Error()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will most of these case be catched by !common.IsContextCanceledError(err) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case should move before case !common.IsContextCanceledError(err):, else it's never run

// recoverable error, should not be recorded in checkpoint
// which will prevent lightning from automatically recovering
return nil
case !common.IsContextCanceledError(err):
merger.SetInvalid()
rc.errorSummaries.record(tableName, err, statusIfSucceed)
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