mirror of
https://github.com/MariaDB/server.git
synced 2025-11-01 03:16:41 +01:00
Gap logs prevented race conditions when a concurrent connection
^
Typo, gap locks.
Integer lax with postfix operator-- allows redundant
long_unique_fields_differ(). I've replaced it with bool logic.
What happens if to replace innodb_row_ins_step_enter with
ha_write_row_end in the first example? Row-level locking works and
ha_index_next_same() of INSERT(5) long unique check is blocked until
INSERT(15) commits. That proves post-write long unique check is enough
for fixing race condition. I've added test case for that.
The below was done by Sachin but the cleanup commit b7905fa61b is
good occasion to fix these.
Redundant if (result == HA_ERR_FOUND_DUPP_KEY) check, same for other
error codes. The below patch brings up understanding at which calls
which error codes overridden to 0.
if (!result) is needless extra indentation level for substantional
amount of code.
For convenience these cleanups are separated on top of b7905fa61b
cleanup for easy merge:
934b9f2868 (mariadb/bb-10.6-midenok-review2, bb-10.6-midenok-review2) MDEV-37199 Cleanup
One more FIXME below for test file. Also innodb_lock_wait_timeout is
not needed for original test cases (nor for unpatched repro).
208 lines
6 KiB
Text
208 lines
6 KiB
Text
--source include/have_innodb.inc
|
|
--source include/have_debug_sync.inc
|
|
|
|
--echo #
|
|
--echo # MDEV-37199 UNIQUE KEY USING HASH accepting duplicate records
|
|
--echo #
|
|
|
|
--echo ## INSERT
|
|
create table t1 (
|
|
id int, s date, e date,
|
|
period for p(s,e),
|
|
unique(id, p without overlaps)
|
|
) engine=innodb;
|
|
|
|
start transaction;
|
|
select * from t1;
|
|
--connect con1,localhost,root
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-11');
|
|
delete from t1;
|
|
set transaction isolation level read committed;
|
|
set debug_sync="innodb_row_ins_step_enter SIGNAL checked_duplicate WAIT_FOR do_insert";
|
|
--send insert t1 values(10, date'2010-09-09', date'2010-11-10')
|
|
--connect con2,localhost,root
|
|
set debug_sync="now WAIT_FOR checked_duplicate";
|
|
set transaction isolation level read committed;
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-12');
|
|
set debug_sync="now SIGNAL do_insert";
|
|
--connection con1
|
|
--error ER_DUP_ENTRY
|
|
--reap
|
|
--connection default
|
|
select * from t1;
|
|
commit;
|
|
select * from t1;
|
|
--disconnect con1
|
|
--disconnect con2
|
|
set debug_sync='RESET';
|
|
drop table t1;
|
|
|
|
--echo ## UPDATE
|
|
create table t1 (
|
|
id int, s date, e date,
|
|
period for p(s,e),
|
|
unique(id, p without overlaps)
|
|
) engine=innodb;
|
|
|
|
start transaction;
|
|
select * from t1;
|
|
--connect con1,localhost,root
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-11');
|
|
delete from t1;
|
|
insert t1 values(10, date'2010-09-09', date'2010-09-10');
|
|
insert t1 values(10, date'2010-12-10', date'2010-12-12');
|
|
set transaction isolation level read committed;
|
|
set debug_sync="innodb_row_update_for_mysql_begin SIGNAL checked_duplicate WAIT_FOR do_insert";
|
|
--send update t1 set e=e + interval 2 month where s=date'2010-09-09'
|
|
--connect con2,localhost,root
|
|
set debug_sync="now WAIT_FOR checked_duplicate";
|
|
set transaction isolation level read committed;
|
|
update t1 set s=date'2010-10-10' where e=date'2010-12-12';
|
|
set debug_sync="now SIGNAL do_insert";
|
|
--connection con1
|
|
--error ER_DUP_ENTRY
|
|
--reap
|
|
--connection default
|
|
select * from t1;
|
|
commit;
|
|
select * from t1;
|
|
--disconnect con1
|
|
--disconnect con2
|
|
set debug_sync='RESET';
|
|
drop table t1;
|
|
|
|
--echo ## INSERT IGNORE
|
|
create table t1 (
|
|
id int, s date, e date,
|
|
period for p(s,e),
|
|
unique(id, p without overlaps)
|
|
) engine=innodb;
|
|
|
|
start transaction;
|
|
select * from t1;
|
|
--connect con1,localhost,root
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-11');
|
|
delete from t1;
|
|
set transaction isolation level read committed;
|
|
set debug_sync="innodb_row_ins_step_enter SIGNAL checked_duplicate WAIT_FOR do_insert";
|
|
--send insert ignore t1 values(10, date'2010-09-09', date'2010-11-10'),(11, date'2010-09-09', date'2010-11-10')
|
|
--connect con2,localhost,root
|
|
set debug_sync="now WAIT_FOR checked_duplicate";
|
|
set transaction isolation level read committed;
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-12');
|
|
set debug_sync="now SIGNAL do_insert";
|
|
--connection con1
|
|
--reap
|
|
--connection default
|
|
select * from t1;
|
|
commit;
|
|
select * from t1;
|
|
--disconnect con1
|
|
--disconnect con2
|
|
set debug_sync='RESET';
|
|
drop table t1;
|
|
|
|
--echo ## UPDATE IGNORE
|
|
create table t1 (
|
|
id int, s date, e date,
|
|
period for p(s,e),
|
|
unique(id, p without overlaps)
|
|
) engine=innodb;
|
|
|
|
start transaction;
|
|
select * from t1;
|
|
--connect con1,localhost,root
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-11');
|
|
delete from t1;
|
|
insert t1 values(10, date'2010-09-09', date'2010-09-10');
|
|
insert t1 values(10, date'2010-12-10', date'2010-12-12');
|
|
set transaction isolation level read committed;
|
|
set debug_sync="innodb_row_update_for_mysql_begin SIGNAL checked_duplicate WAIT_FOR do_insert";
|
|
--send update ignore t1 set e=e + interval 2 month where s=date'2010-09-09'
|
|
--connect con2,localhost,root
|
|
set debug_sync="now WAIT_FOR checked_duplicate";
|
|
set transaction isolation level read committed;
|
|
update t1 set s=date'2010-10-10' where e=date'2010-12-12';
|
|
set debug_sync="now SIGNAL do_insert";
|
|
--connection con1
|
|
--reap
|
|
--connection default
|
|
select * from t1;
|
|
commit;
|
|
select * from t1;
|
|
--disconnect con1
|
|
--disconnect con2
|
|
set debug_sync='RESET';
|
|
drop table t1;
|
|
|
|
--echo ## UPDATE modifying PK
|
|
create table t1 (
|
|
id int, s date, e date,
|
|
period for p(s,e),
|
|
primary key (id, p without overlaps)
|
|
) engine=innodb;
|
|
|
|
start transaction;
|
|
select * from t1;
|
|
--connect con1,localhost,root
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-11');
|
|
delete from t1;
|
|
insert t1 values(10, date'2010-09-09', date'2010-09-10');
|
|
insert t1 values(10, date'2010-12-10', date'2010-12-12');
|
|
set transaction isolation level read committed;
|
|
set debug_sync="innodb_row_update_for_mysql_begin SIGNAL checked_duplicate WAIT_FOR do_insert";
|
|
--send update t1 set e=e + interval 2 month where s=date'2010-09-09'
|
|
--connect con2,localhost,root
|
|
set debug_sync="now WAIT_FOR checked_duplicate";
|
|
set transaction isolation level read committed;
|
|
update t1 set s=date'2010-10-10' where e=date'2010-12-12';
|
|
set debug_sync="now SIGNAL do_insert";
|
|
--connection con1
|
|
--error ER_DUP_ENTRY
|
|
--reap
|
|
--connection default
|
|
select * from t1;
|
|
commit;
|
|
select * from t1;
|
|
--disconnect con1
|
|
--disconnect con2
|
|
set debug_sync='RESET';
|
|
drop table t1;
|
|
|
|
--echo ## UPDATE IGNORE modifying PK
|
|
create table t1 (
|
|
id int, s date, e date,
|
|
period for p(s,e),
|
|
primary key (id, p without overlaps)
|
|
) engine=innodb;
|
|
|
|
start transaction;
|
|
select * from t1;
|
|
--connect con1,localhost,root
|
|
insert t1 values(10, date'2010-10-10', date'2010-11-11');
|
|
delete from t1;
|
|
insert t1 values(10, date'2010-09-09', date'2010-09-10');
|
|
insert t1 values(10, date'2010-12-10', date'2010-12-12');
|
|
set transaction isolation level read committed;
|
|
set debug_sync="innodb_row_update_for_mysql_begin SIGNAL checked_duplicate WAIT_FOR do_insert";
|
|
--send update ignore t1 set e=e + interval 2 month where s=date'2010-09-09'
|
|
--connect con2,localhost,root
|
|
set debug_sync="now WAIT_FOR checked_duplicate";
|
|
set transaction isolation level read committed;
|
|
update t1 set s=date'2010-10-10' where e=date'2010-12-12';
|
|
set debug_sync="now SIGNAL do_insert";
|
|
--connection con1
|
|
--error ER_NOT_SUPPORTED_YET
|
|
--reap
|
|
--connection default
|
|
select * from t1;
|
|
commit;
|
|
select * from t1;
|
|
--disconnect con1
|
|
--disconnect con2
|
|
set debug_sync='RESET';
|
|
drop table t1;
|
|
|
|
|
|
--echo # End of 10.6 tests
|
|
|