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

add index: GetNextStep for mergeStep may ignore error #47932

Closed
ywqzzy opened this issue Oct 23, 2023 · 0 comments · Fixed by #47886
Closed

add index: GetNextStep for mergeStep may ignore error #47932

ywqzzy opened this issue Oct 23, 2023 · 0 comments · Fixed by #47886
Labels
affects-7.5 component/ddl This issue is related to DDL of TiDB. severity/major type/bug This issue is a bug.

Comments

@ywqzzy
Copy link
Contributor

ywqzzy commented Oct 23, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

func TestGlobalSortBasic(t *testing.T) {
	gcsHost, gcsPort, cloudStorageURI := genStorageURI(t)
	opt := fakestorage.Options{
		Scheme:     "http",
		Host:       gcsHost,
		Port:       gcsPort,
		PublicHost: gcsHost,
	}
	server, err := fakestorage.NewServerWithOptions(opt)
	require.NoError(t, err)
	server.CreateBucketWithOpts(fakestorage.CreateBucketOpts{Name: "sorted"})

	store, dom := realtikvtest.CreateMockStoreAndDomainAndSetup(t)
	tk := testkit.NewTestKit(t, store)
	require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/disttask/framework/dispatcher/WaitCleanUpFinished", "return()"))
	tk.MustExec("drop database if exists addindexlit;")
	tk.MustExec("create database addindexlit;")
	tk.MustExec("use addindexlit;")
	tk.MustExec(`set @@global.tidb_ddl_enable_fast_reorg = 1;`)
	tk.MustExec("set @@global.tidb_enable_dist_task = 1;")
	tk.MustExec(fmt.Sprintf(`set @@global.tidb_cloud_storage_uri = "%s"`, cloudStorageURI))
	defer func() {
		tk.MustExec("set @@global.tidb_enable_dist_task = 0;")
		variable.CloudStorageURI.Store("")
	}()

	tk.MustExec("create table t (a int, b int, c int);")
	var sb strings.Builder
	sb.WriteString("insert into t values ")
	size := 100
	for i := 0; i < size; i++ {
		sb.WriteString(fmt.Sprintf("(%d, %d, %d)", i, i, i))
		if i != size-1 {
			sb.WriteString(",")
		}
	}
	sb.WriteString(";")
	tk.MustExec(sb.String())

	var jobID int64
	origin := dom.DDL().GetHook()
	onJobUpdated := func(job *model.Job) {
		jobID = job.ID
	}
	hook := &callback.TestDDLCallback{}
	hook.OnJobUpdatedExported.Store(&onJobUpdated)
	dom.DDL().SetHook(hook)

	tk.MustExec("alter table t add index idx(a);")
	dom.DDL().SetHook(origin)
	tk.MustExec("admin check table t;")
	<-dispatcher.WaitCleanUpFinished
	checkFileCleaned(t, jobID, cloudStorageURI)

	require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/ddl/forceMergeSort", "return()"))
	tk.MustExec("alter table t add index idx1(a);")
	dom.DDL().SetHook(origin)
	tk.MustExec("admin check table t;")
	<-dispatcher.WaitCleanUpFinished

	checkFileCleaned(t, jobID, cloudStorageURI)
	require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/disttask/framework/dispatcher/WaitCleanUpFinished"))
	require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/ddl/forceMergeSort"))
}

2. What did you expect to see? (Required)

Run merge sort step.

3. What did you see instead (Required)

Don't run merge sort step

4. What is your TiDB version? (Required)

master

@ywqzzy ywqzzy added the type/bug This issue is a bug. label Oct 23, 2023
@ywqzzy ywqzzy changed the title add index:GetNextStep may emit error add index: GetNextStep may emit error Oct 23, 2023
@ywqzzy ywqzzy changed the title add index: GetNextStep may emit error add index: GetNextStep may ignore error Oct 23, 2023
@ywqzzy ywqzzy changed the title add index: GetNextStep may ignore error add index: GetNextStep for mergeStep may ignore error Oct 23, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Oct 23, 2023
@wjhuang2016 wjhuang2016 removed may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Oct 23, 2023
@jebter jebter added the component/ddl This issue is related to DDL of TiDB. label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 component/ddl This issue is related to DDL of TiDB. severity/major type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants