Open zephyrleaves opened 12 years ago
I tried executing multiple inserts within a single transaction, and it worked fine. I have no idea how to reproduce your problem. Please provide a working script reproducing the error.
The multiple inserts must be in 2 tables and the variable innodb_autoinc_lock_mode should be 1. In one transaction,the script need like insert into test1 (data) values ('1'); insert into test1 (data) values ('2'); insert into test2 (data) values ('3'); 2 inserts in test1 and then 1 insert in test2,it will reproduce .
When insert three rows with two tables in a epoll_wait time , it will make "update_auto_increment()" failed and return "HA_ERR_AUTOINC_ERANGE" ,becase the nr will be 0.
Like table: CREATE TABLE
testx
(id
int(20) unsigned NOT NULL AUTO_INCREMENT,data
varchar(200) DEFAULT NULL, PRIMARY KEY (id
) ) ENGINE=InnoDB AUTO_INCREMENT=1DEFAULT;exeucte commands like sql below in a epoll_wait time twice: insert into test1 (data) values ('1'); insert into test1 (data) values ('2'); insert into test2 (data) values ('3'); It will return HA_ERR_AUTOINC_ERANGE(167).
Because the "trx" is in THD and two table has two "prebuilt" ,it will make mistake on "trx->n_autoinc_rows" and "prebuilt->autoinc_last_value".
I think should use "hnd->start_stmt(thd,TL_WRITE)" in "dbcontext::cmd_insert_internal() " before the "const int r = hnd->ha_write_row(buf)" ,this will reset the "trx->n_autoinc_rows" ,and make "update_auto_increment()" success!