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: fix integration test failed #49662

Merged
merged 2 commits into from
Dec 21, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions br/pkg/lightning/checkpoints/checkpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -1610,16 +1610,17 @@ func (cpdb *MySQLCheckpointsDB) IgnoreErrorCheckpoint(ctx context.Context, table
colName = columnTableName
}

query := "UPDATE ?.? SET status = ? WHERE ? = ? AND status <= ?"
s := common.SQLWithRetry{
DB: cpdb.db,
Logger: log.FromContext(ctx).With(zap.String("table", tableName)),
}
err := s.Transact(ctx, "ignore error checkpoints", func(c context.Context, tx *sql.Tx) error {
if _, e := tx.ExecContext(c, query, cpdb.schema, CheckpointTableNameEngine, CheckpointStatusLoaded, colName, tableName, CheckpointStatusMaxInvalid); e != nil {
query := fmt.Sprintf("UPDATE %s.%s SET status = ? WHERE ? = ? AND status <= ?", cpdb.schema, CheckpointTableNameEngine)
if _, e := tx.ExecContext(c, query, CheckpointStatusLoaded, colName, tableName, CheckpointStatusMaxInvalid); e != nil {
return errors.Trace(e)
}
if _, e := tx.ExecContext(c, query, cpdb.schema, CheckpointTableNameTable, CheckpointStatusLoaded, colName, tableName, CheckpointStatusMaxInvalid); e != nil {
query = fmt.Sprintf("UPDATE %s.%s SET status = ? WHERE ? = ? AND status <= ?", cpdb.schema, CheckpointTableNameTable)
if _, e := tx.ExecContext(c, query, CheckpointStatusLoaded, colName, tableName, CheckpointStatusMaxInvalid); e != nil {
return errors.Trace(e)
}
return nil
Expand Down
16 changes: 8 additions & 8 deletions br/pkg/lightning/checkpoints/checkpoints_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,12 @@ func TestIgnoreAllErrorCheckpoints_SQL(t *testing.T) {

s.mock.ExpectBegin()
s.mock.
ExpectExec("UPDATE \\?\\.\\? SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs("`mock-schema`", checkpoints.CheckpointTableNameEngine, checkpoints.CheckpointStatusLoaded, "'all'", sqlmock.AnyArg(), 25).
ExpectExec("UPDATE `mock-schema`\\.engine_v\\d+ SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs(checkpoints.CheckpointStatusLoaded, "'all'", sqlmock.AnyArg(), 25).
WillReturnResult(sqlmock.NewResult(5, 3))
s.mock.
ExpectExec("UPDATE \\?\\.\\? SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs("`mock-schema`", checkpoints.CheckpointTableNameTable, checkpoints.CheckpointStatusLoaded, "'all'", sqlmock.AnyArg(), 25).
ExpectExec("UPDATE `mock-schema`\\.table_v\\d+ SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs(checkpoints.CheckpointStatusLoaded, "'all'", sqlmock.AnyArg(), 25).
WillReturnResult(sqlmock.NewResult(6, 2))
s.mock.ExpectCommit()

Expand All @@ -413,12 +413,12 @@ func TestIgnoreOneErrorCheckpoint(t *testing.T) {

s.mock.ExpectBegin()
s.mock.
ExpectExec("UPDATE \\?\\.\\? SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs("`mock-schema`", checkpoints.CheckpointTableNameEngine, checkpoints.CheckpointStatusLoaded, "table_name", "`db1`.`t2`", 25).
ExpectExec("UPDATE `mock-schema`\\.engine_v\\d+ SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs(checkpoints.CheckpointStatusLoaded, "table_name", "`db1`.`t2`", 25).
WillReturnResult(sqlmock.NewResult(5, 2))
s.mock.
ExpectExec("UPDATE \\?\\.\\? SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs("`mock-schema`", checkpoints.CheckpointTableNameTable, checkpoints.CheckpointStatusLoaded, "table_name", "`db1`.`t2`", 25).
ExpectExec("UPDATE `mock-schema`\\.table_v\\d+ SET status = \\? WHERE \\? = \\? AND status <= \\?").
WithArgs(checkpoints.CheckpointStatusLoaded, "table_name", "`db1`.`t2`", 25).
WillReturnResult(sqlmock.NewResult(6, 1))
s.mock.ExpectCommit()

Expand Down