Skip to content

Commit 3b801d9

Browse files
committed
lightning: make OpLevelOptional suppress the error of DoChecksum
1 parent 39d8c16 commit 3b801d9

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

disttask/importinto/subtask_executor.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,27 @@ func verifyChecksum(ctx context.Context, taskMeta *TaskMeta, subtaskMeta *PostPr
120120
}
121121
remoteChecksum, err := checksumTable(ctx, globalTaskManager, taskMeta, logger)
122122
if err != nil {
123-
return err
123+
if taskMeta.Plan.Checksum != config.OpLevelOptional {
124+
return err
125+
}
126+
logger.Warn("checksumTable failed, will skip this error and go on", zap.Error(err))
127+
err = nil
124128
}
125-
if !remoteChecksum.IsEqual(&localChecksum) {
126-
err2 := common.ErrChecksumMismatch.GenWithStackByArgs(
127-
remoteChecksum.Checksum, localChecksum.Sum(),
128-
remoteChecksum.TotalKVs, localChecksum.SumKVS(),
129-
remoteChecksum.TotalBytes, localChecksum.SumSize(),
130-
)
131-
if taskMeta.Plan.Checksum == config.OpLevelOptional {
132-
logger.Warn("verify checksum failed, but checksum is optional, will skip it", zap.Error(err2))
133-
err2 = nil
129+
if remoteChecksum != nil {
130+
if !remoteChecksum.IsEqual(&localChecksum) {
131+
err2 := common.ErrChecksumMismatch.GenWithStackByArgs(
132+
remoteChecksum.Checksum, localChecksum.Sum(),
133+
remoteChecksum.TotalKVs, localChecksum.SumKVS(),
134+
remoteChecksum.TotalBytes, localChecksum.SumSize(),
135+
)
136+
if taskMeta.Plan.Checksum == config.OpLevelOptional {
137+
logger.Warn("verify checksum failed, but checksum is optional, will skip it", zap.Error(err2))
138+
err2 = nil
139+
}
140+
return err2
134141
}
135-
return err2
142+
logger.Info("checksum pass", zap.Object("local", &localChecksum))
136143
}
137-
logger.Info("checksum pass", zap.Object("local", &localChecksum))
138144
return nil
139145
}
140146

0 commit comments

Comments
 (0)