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

[Bug]: alter add foreign key concurrent 50 threads reported w-w conflict error #20783

Open
1 task done
heni02 opened this issue Dec 17, 2024 · 1 comment
Open
1 task done
Assignees
Labels
kind/bug Something isn't working severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Milestone

Comments

@heni02
Copy link
Contributor

heni02 commented Dec 17, 2024

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

2.0-dev

Commit ID

d570bbd

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

测试场景:alter table add foreign key并发50执行5分钟
测试结果:sql报错w-w conflict
测试sql:alter table table_{id} add constraint fk_{id} foreign key(col2) references fk_01(col1);(100个表创建外键依赖fk_01 col1列)
image

单独顺序执行是可以的
image

ddl:
create table concurrent_test.fk_01(col1 int not null primary key,col2 int);insert into concurrent_test.fk_01 values (90,5983),(100,734),(190,50);
create table concurrent_test.table_$i(col1 bigint primary key auto_increment,col2 int)

另外同时并发alter add foreign和alter drop foreign key测试,两个sql也是会报w-w conflict
image

Expected Behavior

No response

Steps to Reproduce

1. git clone mo-load工具
2. 准备mo 100个表数据:
 mysql -h 127.0.0.1 -udump -P6001 -p111 -e "drop database if exists concurrent_test;create database concurrent_test;create table concurrent_test.fk_01(col1 int not null primary key,col2 int);insert into concurrent_test.fk_01 values (90,5983),(100,734),(190,50);"

for i in {1..100}; do mysql -h 127.0.0.1 -udump -P6001 -p111 -e "create table concurrent_test.table_$i(col1 bigint primary key auto_increment,col2 int)";done
3.执行并发50测试
cd mo-load
./start.sh -h 127.0.0.1  -b concurrent_test -c cases/ddl/alter_add_drop_foreign_key/ (此命令是同时并发alter add和drop foreign key,如果只单独并发alter add,vim cases/ddl/alter_add_drop_foreign_key/run.yaml删除-name:"alter_drop_fk"以下一段case,再执行该命令即可)

如果

Additional information

No response

@heni02 heni02 added kind/bug Something isn't working severity/s0 Extreme impact: Cause the application to break down and seriously affect the use labels Dec 17, 2024
@heni02 heni02 added this to the 2.1.0 milestone Dec 17, 2024
@ouyuanning
Copy link
Contributor

根本原因是当设计到外键的时候。是有更改外键表的schema的。而没有给外键表加锁造成的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Projects
None yet
Development

No branches or pull requests

2 participants