innodb autoinc lockmodes 0 and 1 cause hanging
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MySQL patches by Codership |
New
|
Undecided
|
Unassigned | ||
5.5 |
Confirmed
|
Wishlist
|
Seppo Jaakola |
Bug Description
having innodb_
Checking the stack trace shows that slave thread is waiting for autoinc lock.
To repeat, you can start two node cluster (ardennes and batak in this example) and create two tables:
mysql> create table t1 (i int auto_increment primary key, j int);
mysql> create table t2 ( j int);
Table t2 is needed to generate bulk mode insert on t1 later on. Insert one row in t2:
mysql> insert into t2 values (200);
Then start a batch of autocommit insert against node batak:
$ for ((i=0;i<
using another terminal start "bulk mode" inserts on t1 in node ardennes:
$ for ((i=0;i<
both connections will hang pretty soon.
Changed in codership-mysql: | |
assignee: | nobody → seppo-jaakola |
importance: | Undecided → High |
milestone: | none → 0.6 |
status: | New → In Progress |
Changed in codership-mysql: | |
importance: | High → Medium |
milestone: | 0.6 → 0.6.1 |
Changed in codership-mysql: | |
milestone: | 0.6.1 → 0.7 |
Changed in codership-mysql: | |
milestone: | 0.7 → 0.8 |
Changed in codership-mysql: | |
status: | In Progress → Confirmed |
Changed in codership-mysql: | |
milestone: | 0.8 → none |
milestone: | none → 0.8 |
milestone: | 0.8 → none |
no longer affects: | codership-mysql/0.8 |
Changed in codership-mysql: | |
milestone: | 5.5.33-23.7.6 → none |
Changed in codership-mysql: | |
assignee: | Seppo Jaakola (seppo-jaakola) → nobody |
importance: | Wishlist → Undecided |
status: | Confirmed → New |
Reason for the deadlock is in table level autoinc lock.
Local bulk mode inserts (autocommit trx) grab autoinc lock and keep it until the end of statement.
Slave applier needs to honor this lock and must wait for it. This is a deadlock, because local autocommit insert cannot proceed past commit phase before slave applier has released TO mutex.
Workaround is to set innodb_ autoinc_ lock_mode= 2. This avoids using autoinc locking altogether.
In the test cluster, hanging does not reproduce with autoinc lock mode 2.