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

*: insufficient bytes decode value reported when adding index for some split common-handled tables. #20727

Closed
bb7133 opened this issue Oct 29, 2020 · 2 comments · Fixed by #20908
Assignees
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@bb7133
Copy link
Member

bb7133 commented Oct 29, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

tidb> show variables like '%clustered%';


+-----------------------------+-------+
| Variable_name               | Value |
+-----------------------------+-------+
| tidb_enable_clustered_index | ON    |
+-----------------------------+-------+
1 row in set (0.02 sec)
tidb> create table t (a varchar(255), b int, primary key(a));
Query OK, 0 rows affected (0.02 sec)

tidb> insert into t values ('a', 1), ('b', 2), ('c', 3), ('u', 1);
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

tidb> split table t between ('a') and ('z') regions 5;
+--------------------+----------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
+--------------------+----------------------+
|                  4 |                    1 |
+--------------------+----------------------+
1 row in set (0.01 sec)

tidb> create index idx on t (b);

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

The job ran successfully.

3. What did you see instead (Required)

Error reported when executing the DDL job:

[worker="worker 2, tp add index"] [error="insufficient bytes to decode value"] [errorVerbose="insufficient bytes to decode value
github.com/pingcap/tidb/util/codec.peekBytes
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/util/codec/codec.go:958
github.com/pingcap/tidb/util/codec.peek
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/util/codec/codec.go:933
github.com/pingcap/tidb/util/codec.CutOne
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/util/codec/codec.go:887
github.com/pingcap/tidb/kv.NewCommonHandle
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/kv/key.go:248
github.com/pingcap/tidb/tablecodec.DecodeRowKey
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/tablecodec/tablecodec.go:269
github.com/pingcap/tidb/ddl.decodeHandleRange
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/backfilling.go:364
github.com/pingcap/tidb/ddl.(*worker).sendRangeTaskToWorkers
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/backfilling.go:380
github.com/pingcap/tidb/ddl.(*worker).writePhysicalTableRecord
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/backfilling.go:563
github.com/pingcap/tidb/ddl.(*worker).addPhysicalTableIndex
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1142
github.com/pingcap/tidb/ddl.(*worker).addTableIndex
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:1165
github.com/pingcap/tidb/ddl.(*worker).onCreateIndex.func1
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/index.go:564
github.com/pingcap/tidb/ddl.(*worker).runReorgJob.func1
	/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/ddl/reorg.go:190
runtime.goexit
	/home/bb7133/Softwares/go/src/runtime/asm_amd64.s:1374"]

4. What is your TiDB version? (Required)

This can be reproduced in the master version

Root Cause

For now, ADD INDEX(as well as some other DDL jobs that need data-reorganization) assume that the 'startKey' and 'endKey' of a region can always be decoded:

func decodeHandleRange(keyRange kv.KeyRange) (kv.Handle, kv.Handle, error) {

But it is not the case for:

@ti-srebot
Copy link
Contributor

ti-srebot commented Nov 11, 2020

Please edit this comment to complete the following information

Bug

1. Root Cause Analysis (RCA) (optional)

For now, ADD INDEX(as well as some other DDL jobs that need data-reorganization) assume that the 'startKey' and 'endKey' of a region can always be decoded:

func decodeHandleRange(keyRange kv.KeyRange) (kv.Handle, kv.Handle, error) {

2. Symptom (optional)

Report error: insufficient bytes to decode value.

3. All Trigger Conditions (optional)

  • Enable clustered index.
  • Split table with SPLIT ... BETWEEN ... statement.
  • Add index / Change column type / Drop partition with global index

4. Workaround (optional)

No workaround.

5. Affected versions

unreleased

6. Fixed versions

master

@ti-srebot
Copy link
Contributor

( component or sig(label) ) fields are empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants