Skip to content

Commit

Permalink
ddl: improve test
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jan 29, 2022
1 parent b8a1758 commit bdba3fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 0 additions & 3 deletions ddl/callback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import (
"go.uber.org/zap"
)

// TestReorgGoroutineRunning is only used in test to indicate the reorg goroutine has been started.
var TestReorgGoroutineRunning = make(chan interface{})

type TestInterceptor struct {
*BaseInterceptor

Expand Down
6 changes: 4 additions & 2 deletions ddl/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/testkit"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util"
"github.com/pingcap/tidb/util/collate"
Expand Down Expand Up @@ -1152,12 +1151,15 @@ func (w *worker) updatePhysicalTableRow(t table.PhysicalTable, oldColInfo, colIn
return w.writePhysicalTableRecord(t, typeUpdateColumnWorker, nil, oldColInfo, colInfo, reorgInfo)
}

// TestReorgGoroutineRunning is only used in test to indicate the reorg goroutine has been started.
var TestReorgGoroutineRunning = make(chan interface{})

// updateColumnAndIndexes handles the modify column reorganization state for a table.
func (w *worker) updateColumnAndIndexes(t table.Table, oldCol, col *model.ColumnInfo, idxes []*model.IndexInfo, reorgInfo *reorgInfo) error {
failpoint.Inject("mockInfiniteReorgLogic", func(val failpoint.Value) {
if val.(bool) {
a := new(interface{})
testkit.TestReorgGoroutineRunning <- a
TestReorgGoroutineRunning <- a
for {
time.Sleep(30 * time.Millisecond)
if w.reorgCtx.isReorgCanceled() {
Expand Down
2 changes: 1 addition & 1 deletion ddl/column_type_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ func TestCancelCTCInReorgStateWillCauseGoroutineLeak(t *testing.T) {
// This ddl will be hang over in the failpoint loop, waiting for outside cancel.
_, alterErr = tk1.Exec("alter table ctc_goroutine_leak modify column a tinyint")
}()
<-testkit.TestReorgGoroutineRunning
<-TestReorgGoroutineRunning
tk.MustExec("admin cancel ddl jobs " + strconv.Itoa(int(jobID)))
wg.Wait()
require.Equal(t, "[ddl:8214]Cancelled DDL job", alterErr.Error())
Expand Down

0 comments on commit bdba3fa

Please sign in to comment.