Skip to content

Commit dab6419

Browse files
committed
fix conflict
1 parent dbac5f1 commit dab6419

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

ddl/ddl_ops.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -526,23 +526,20 @@ func (c *testCase) execParaDDLSQL(taskCh chan *ddlJobTask, num int) error {
526526
defer wg.Done()
527527
opStart := time.Now()
528528
db := c.pickupDB()
529-
err := c.executeWithTimeout(db, task)
530-
if !ddlIgnoreError(err) {
531-
log.Infof("[ddl] [instance %d] TiDB execute %s , err %v, elapsed time:%v", c.caseIndex, task.sql, err, time.Since(opStart).Seconds())
532-
task.err = err
533-
db := c.dbs[0]
534529
conn, err := db.Conn(context.Background())
530+
if err != nil {
531+
unExpectedErr = err
532+
return
533+
}
535534
defer func() {
536535
err := conn.Close()
537536
if err != nil {
538537
log.Errorf("error when closes conn %s", err.Error())
539538
}
540539
}()
541-
if err != nil {
542-
unExpectedErr = err
543-
return
544-
}
545-
_, ddlErr := conn.ExecContext(context.Background(), task.sql)
540+
ddlErr := c.executeWithTimeout(task, func(ctx context.Context, s string) (sql.Result, error) {
541+
return conn.ExecContext(ctx, s)
542+
})
546543
if !ddlIgnoreError(ddlErr) {
547544
log.Infof("[ddl] [instance %d] TiDB execute %s , err %v, elapsed time:%v", c.caseIndex, task.sql, err, time.Since(opStart).Seconds())
548545
task.err = ddlErr
@@ -626,7 +623,9 @@ func (c *testCase) execSerialDDLSQL(taskCh chan *ddlJobTask) error {
626623
task := <-taskCh
627624
db := c.pickupDB()
628625
opStart := time.Now()
629-
err := c.executeWithTimeout(db, task)
626+
err := c.executeWithTimeout(task, func(ctx context.Context, s string) (sql.Result, error) {
627+
return db.ExecContext(ctx, task.sql)
628+
})
630629
log.Infof("[ddl] [instance %d] %s, err: %v, elapsed time:%v", c.caseIndex, task.sql, err, time.Since(opStart).Seconds())
631630
if err != nil {
632631
if ddlIgnoreError(err) {

ddl/meta.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type testCase struct {
3838
lastDDLID int
3939
charsets []string
4040
charsetsCollates map[string][]string
41-
updateSchemaMu sync.Mutex
4241
}
4342

4443
type ddlTestErrorConflict struct {
@@ -104,7 +103,7 @@ func (c *testCase) pickupDB() *sql.DB {
104103
return c.dbs[rand.Intn(len(c.dbs)-1)]
105104
}
106105

107-
func (c *testCase) executeWithTimeout(db *sql.DB, task *ddlJobTask) error {
106+
func (c *testCase) executeWithTimeout(task *ddlJobTask, f func(ctx context.Context, s string) (sql.Result, error)) error {
108107
time.Sleep(time.Millisecond * time.Duration(rand.Intn(30)))
109108
t := time.Second * 30
110109
switch task.k {
@@ -116,7 +115,7 @@ func (c *testCase) executeWithTimeout(db *sql.DB, task *ddlJobTask) error {
116115
t = t * time.Duration(runningDDLCount)
117116
ctx, cancel := context.WithTimeout(context.Background(), t)
118117
defer cancel()
119-
_, err := db.ExecContext(ctx, task.sql)
118+
_, err := f(ctx, task.sql)
120119
return errors.Annotate(err, task.sql)
121120
}
122121

0 commit comments

Comments
 (0)