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

ddl: fix panic when add index of generated column. #8620

Merged
merged 8 commits into from Dec 11, 2018
Merged

ddl: fix panic when add index of generated column. #8620

merged 8 commits into from Dec 11, 2018

Conversation

winkyao
Copy link
Contributor

@winkyao winkyao commented Dec 7, 2018

What problem does this PR solve?

exec below sqls:

CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL,
  `c` int(11) GENERATED ALWAYS AS (`a` + `b`) VIRTUAL DEFAULT NULL,
  `h` varchar(10) DEFAULT NULL,
  `m` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

insert into t values();
alter table t add index idx_c(c);

DDL add index worker will panic with:

2018/12/07 08:31:48.263 index.go:1050: [info] [ddl-reorg] start to reorg index of 1 region ranges, handle range:[1, 1).
2018/12/07 08:31:48.265 index.go:829: [error] [ddl-reorg] addIndexWorker assignment to entry in nil map goroutine 108175 [running]:
github.com/pingcap/tidb/util.GetStack(0xc00696d0f0, 0x12c0d60, 0x1643c10)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/misc.go:53 +0x74
github.com/pingcap/tidb/ddl.(*addIndexWorker).run.func1(0xc00e59a000)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:828 +0xda
panic(0x12c0d60, 0x1643c10)
	/usr/local/go/src/runtime/panic.go:513 +0x1b9
github.com/pingcap/tidb/util/rowDecoder.RowDecoder.DecodeAndEvalRowWithMap(0xc00dcac9f0, 0x0, 0xc00dcac6f0, 0xc00dcac930, 0x1, 0x1680260, 0xc00dbcacb0, 0xc00efa8df0, 0x1, 0x8, ...)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/rowDecoder/decoder.go:109 +0x620
github.com/pingcap/tidb/ddl.(*addIndexWorker).getIndexRecord(0xc00e59a000, 0x1, 0xc008ab7e80, 0x13, 0x13, 0xc00efa8df0, 0x1, 0x8, 0xb, 0xc008ab7e80, ...)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:530 +0x187
github.com/pingcap/tidb/ddl.(*addIndexWorker).fetchRowColVals.func1(0x1, 0xc008ab7e80, 0x13, 0x13, 0xc00efa8df0, 0x1, 0x8, 0x165e140, 0xc00da79570, 0x0)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:621 +0x1ca
github.com/pingcap/tidb/ddl.iterateSnapshotRows(0x16687c0, 0xc0004420f0, 0x1, 0x1681a60, 0xc00d3740d0, 0x59e1f2d47d00001, 0x1, 0x1, 0xc00676e001, 0xc00696da68, ...)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:1235 +0x3f4
github.com/pingcap/tidb/ddl.(*addIndexWorker).fetchRowColVals(0xc00e59a000, 0x16819a0, 0xc0066350e0, 0x3f, 0x1, 0x1, 0x1, 0x0, 0x1659c80, 0xc00010e000, ...)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:605 +0x22c
github.com/pingcap/tidb/ddl.(*addIndexWorker).backfillIndexInTxn.func1(0x16819a0, 0xc0066350e0, 0xc0066350e0, 0x0)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:729 +0xfb
github.com/pingcap/tidb/kv.RunInNewTxn(0x16687c0, 0xc0004420f0, 0xc000442001, 0xc00696dce8, 0xc0066a8000, 0xc000483cf8)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/kv/txn.go:49 +0xdb
github.com/pingcap/tidb/ddl.(*addIndexWorker).backfillIndexInTxn(0xc00e59a000, 0x3f, 0x1, 0x1, 0x1524a01, 0x0, 0x203000, 0x0, 0x0, 0xc0001083a0, ...)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:724 +0x12e
github.com/pingcap/tidb/ddl.(*addIndexWorker).handleBackfillTask(0xc00e59a000, 0xc007e9e0a0, 0xc008ab7de0, 0x1)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:785 +0x14f
github.com/pingcap/tidb/ddl.(*addIndexWorker).run(0xc00e59a000, 0xc007e9e0a0)
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:851 +0x162
created by github.com/pingcap/tidb/ddl.(*worker).addPhysicalTableIndex
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:1097 +0x20e


2018/12/07 08:31:48.267 index.go:981: [warning] [ddl-reorg] total added index for 0 rows, this task [1,1) add index for 0 failed [ddl:14]reorg worker panic., take time 0.001459317, update handle err <nil>
2018/12/07 08:31:48.267 index.go:854: [info] [ddl-reorg] worker[2] exit
2018/12/07 08:31:48.267 reorg.go:136: [info] [ddl] run reorg job done, handled 0 rows
2018/12/07 08:31:48.267 ddl_worker.go:515: [error] [ddl-worker 4, tp add index] run DDL job err [ddl:14]reorg worker panic.
github.com/pingcap/errors.AddStack
	/home/jenkins/workspace/build_tidb_master/go/pkg/mod/github.com/pingcap/errors@v0.11.0/errors.go:174
github.com/pingcap/errors.Trace
	/home/jenkins/workspace/build_tidb_master/go/pkg/mod/github.com/pingcap/errors@v0.11.0/juju_adaptor.go:12
github.com/pingcap/tidb/ddl.(*worker).waitTaskResults
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:956
github.com/pingcap/tidb/ddl.(*worker).handleReorgTasks
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:969
github.com/pingcap/tidb/ddl.(*worker).sendRangeTaskToWorkers
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:1024
github.com/pingcap/tidb/ddl.(*worker).buildIndexForReorgInfo
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:1051
github.com/pingcap/tidb/ddl.(*worker).addPhysicalTableIndex
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:1100
github.com/pingcap/tidb/ddl.(*worker).addTableIndex
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:1124
github.com/pingcap/tidb/ddl.(*worker).onCreateIndex.func1
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/index.go:327
github.com/pingcap/tidb/ddl.(*worker).runReorgJob.func1
	/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/ddl/reorg.go:118
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1333

This change is Reviewable

Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jackysp
jackysp previously approved these changes Dec 10, 2018
Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jackysp
Copy link
Member

jackysp commented Dec 10, 2018

Please resolve the conflicts.

@jackysp jackysp dismissed their stale review December 10, 2018 10:59

Need another LGTM, because it is a DDL PR.

@jackysp jackysp added the status/LGT2 Indicates that a PR has LGTM 2. label Dec 10, 2018
zimulala
zimulala previously approved these changes Dec 10, 2018
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zimulala
Copy link
Contributor

/run-all-tests

@zimulala zimulala added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Dec 10, 2018
@winkyao
Copy link
Contributor Author

winkyao commented Dec 10, 2018

/run-all-tests

@winkyao
Copy link
Contributor Author

winkyao commented Dec 11, 2018

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra status/LGT3 The PR has already had 3 LGTM. type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants