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

write conflict when create index on partition table #22708

Open
wjhuang2016 opened this issue Feb 3, 2021 · 4 comments
Open

write conflict when create index on partition table #22708

wjhuang2016 opened this issue Feb 3, 2021 · 4 comments
Assignees
Labels
component/tablepartition This issue is related to Table Partition of TiDB. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@wjhuang2016
Copy link
Member

wjhuang2016 commented Feb 3, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t` (
  `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
  PRIMARY KEY (`a`),
  KEY `idx` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH( `a` )
PARTITIONS 20;

shell:
cat 1.sql
INSERT INTO `t` VALUES ();

mysqlslap --query=1.sql -uroot -h127.0.0.1 -P4000 -c 100 --number-of-queries=10000000 --create-schema=test --commit=1

alter table t add index idx(a);

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

No error in tidb.log

3. What did you see instead (Required)

[ERROR] [ddl_worker.go:158] ["[ddl] handle DDL job failed"] [worker="worker 4, tp add index"] [error="[kv:9007]Write conflict, txnStartTS=422642994193104901, conflictStartTS=422642995477610509, conflictCommitTS=422642995477610510, key={metaKey=true, key=DDLJobReorg, field=\u0000\u0000\u0000\u0000\u0000\u0000\ufffdf} primary=[]byte{0x6d, 0x44, 0x44, 0x4c, 0x4a, 0x6f, 0x62, 0x41, 0x64, 0xff, 0x64, 0x49, 0x64, 0x78, 0x4c, 0x69, 0x73, 0x74, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6c, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} [try again later]"]

Analyze:
In addTableIndex:
image
updateReorgInfo would call UpdateDDLReorgHandle() and write the meta key mDDLJobReorgKey

Meanwhile, the background goroutine runReorgJob() would call UpdateDDLReorgStartHandle() and write the meta key mDDLJobReorgKey.

So there will be a write conflict on the meta key.

4. What is your TiDB version? (Required)

4.0.9, 5.0.0 rc

@qw4990
Copy link
Contributor

qw4990 commented Apr 28, 2021

@mahjonp @zhuo-zhi Could you please take a look at this?

@zhuo-zhi
Copy link
Contributor

/assign

@jebter jebter added the sig/planner SIG: Planner label Jun 22, 2021
@winoros winoros added sig/sql-infra SIG: SQL Infra and removed sig/planner SIG: Planner labels Nov 23, 2021
@tiancaiamao tiancaiamao assigned tiancaiamao and unassigned zhuo-zhi Dec 1, 2021
@mjonss
Copy link
Contributor

mjonss commented Feb 14, 2022

Still reproducible in 5.4.0.

@mjonss
Copy link
Contributor

mjonss commented Feb 14, 2022

/component tablepartition

@ti-chi-bot ti-chi-bot added the component/tablepartition This issue is related to Table Partition of TiDB. label Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tablepartition This issue is related to Table Partition of TiDB. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

9 participants