Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions mysql-test/include/gap_lock_error_all.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--let $warning_or_error= ERROR
--source include/gap_lock_error_init.inc

let $select_lock=for update;
Expand All @@ -18,9 +19,5 @@ let $autocommit = 0;
let $autocommit = 1;
--source include/gap_lock_error_select.inc

let $autocommit = 0;
--source include/gap_lock_error_update.inc
let $autocommit = 1;
--source include/gap_lock_error_update.inc

--source include/gap_lock_error_cleanup.inc
4 changes: 3 additions & 1 deletion mysql-test/include/gap_lock_error_cleanup.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
drop table gap1, gap2, gap3;
set global gap_lock_raise_error= off;

drop table gap1, gap2, gap3, gap5, gap6;
if (!$gap_lock_error_skip_partitioning) {
drop table gap4;
}
28 changes: 28 additions & 0 deletions mysql-test/include/gap_lock_error_init.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# ==== Usage ====
#
# [--let $warning_or_error= WARNING | ERROR ]
# --source include/assert_no_warnings.inc
#
# Parameters:
#
# $warning_or_error
# Whether we are expected to raise warning or error.
#

--disable_warnings
drop table if exists gap1,gap2,gap3;
--enable_warnings

eval CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
PRIMARY KEY (id1, id2, id3),
INDEX i (c1)) ENGINE=$engine;
Expand All @@ -23,6 +38,19 @@ while ($i <= $max) {
--enable_query_log

insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);

if (!$gap_lock_error_skip_partitioning) {
insert into gap4 values (1,1), (2,2),(3,3),(4,4),(5,5);
}

eval CREATE TABLE gap5 (
pk int primary key,
a int,
b int,
key(a)
) ENGINE=$engine;
insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
create table gap6 like gap5;
insert into gap6 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);

eval set session gap_lock_raise_error= $warning_or_error;
12 changes: 1 addition & 11 deletions mysql-test/include/gap_lock_error_select.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
eval set session autocommit=$autocommit;
let $is_gaplock_target = `SELECT @@autocommit = 0 && '$select_lock' != '' && '$expect_gap_lock_errors' = 1`;
let $is_gaplock_target = `SELECT @@autocommit = 0 && '$select_lock' != ''`;

if ($is_gaplock_target)
{
Expand Down Expand Up @@ -49,12 +49,6 @@ eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
order by c1 $select_lock;
eval select * from gap3 where id=1 $select_lock;
eval select * from gap4 where id=1 $select_lock;
eval select * from gap4 where id in (1, 2, 3) $select_lock;
--error ER_UNKNOWN_ERROR
eval select * from gap4 $select_lock;
--error ER_UNKNOWN_ERROR
eval select * from gap4 where id between 3 and 7 $select_lock;
}

if (!$is_gaplock_target)
Expand Down Expand Up @@ -82,8 +76,4 @@ eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
order by c1 $select_lock;
eval select * from gap3 where id=1 $select_lock;
eval select * from gap4 where id=1 $select_lock;
eval select * from gap4 where id in (1, 2, 3) $select_lock;
eval select * from gap4 $select_lock;
eval select * from gap4 where id between 3 and 7 $select_lock;
}
1 change: 1 addition & 0 deletions mysql-test/include/gap_lock_error_update.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ eval create table u1(
primary key (c1, c2, c3),
unique key (c3, c1)
) engine=$engine;
set session gap_lock_raise_error=error;
begin;
insert into u1 values (1,1,1,1);
commit;
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/r/all_persisted_variables.result
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ include/assert.inc [Expect 500+ variables in the table. Due to open Bugs, we are

# Test SET PERSIST

include/assert.inc [Expect 489 persisted variables in the table.]
include/assert.inc [Expect 490 persisted variables in the table.]

************************************************************
* 3. Restart server, it must preserve the persisted variable
* settings. Verify persisted configuration.
************************************************************
# restart

include/assert.inc [Expect 489 persisted variables in persisted_variables table.]
include/assert.inc [Expect 489 persisted variables shown as PERSISTED in variables_info table.]
include/assert.inc [Expect 489 persisted variables with matching peristed and global values.]
include/assert.inc [Expect 490 persisted variables in persisted_variables table.]
include/assert.inc [Expect 490 persisted variables shown as PERSISTED in variables_info table.]
include/assert.inc [Expect 490 persisted variables with matching peristed and global values.]

************************************************************
* 4. Test RESET PERSIST IF EXISTS. Verify persisted variable
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/r/mysqld--help-notwin.result
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ The following options may be given as the first argument:
word symbols for full text search queries
--ft-stopword-file=name
Use stopwords from this file instead of built-in list
--gap-lock-raise-error[=name]
Controls raising a warning or an error when executing
queries that rely on Gap Lock. It can take the following
values: OFF: no error is raised WARNING: a warning is
raised ERROR: an error is raised. Default is OFF
--gdb Set up signals usable for debugging.
--general-log Log connections and queries to a table or log file.
Defaults to logging to a file hostname.log, or if
Expand Down Expand Up @@ -1847,6 +1852,7 @@ ft-min-word-len 4
ft-query-expansion-limit 20
ft-query-extra-word-chars FALSE
ft-stopword-file (No default value)
gap-lock-raise-error OFF
gdb FALSE
general-log FALSE
generated-random-password-length 20
Expand Down
14 changes: 13 additions & 1 deletion mysql-test/suite/percona/r/gap_lock_error_memory.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
drop table if exists gap1,gap2,gap3;
CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
PRIMARY KEY (id1, id2, id3),
INDEX i (c1)) ENGINE=memory;
Expand All @@ -6,11 +7,22 @@ CREATE TABLE gap3 (id INT, value INT,
PRIMARY KEY (id),
UNIQUE KEY ui(value)) ENGINE=memory;
insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
CREATE TABLE gap5 (
pk int primary key,
a int,
b int,
key(a)
) ENGINE=memory;
insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
create table gap6 like gap5;
insert into gap6 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
set session gap_lock_raise_error= WARNING;
select sum(value) from gap1;
sum(value)
500500
update gap1 set gap1.value= (select count(*) from gap2);
select sum(value) from gap1;
sum(value)
1000000
drop table gap1, gap2, gap3;
set global gap_lock_raise_error= off;
drop table gap1, gap2, gap3, gap5, gap6;
14 changes: 13 additions & 1 deletion mysql-test/suite/percona/r/gap_lock_error_myisam.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
drop table if exists gap1,gap2,gap3;
CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
PRIMARY KEY (id1, id2, id3),
INDEX i (c1)) ENGINE=myisam;
Expand All @@ -6,11 +7,22 @@ CREATE TABLE gap3 (id INT, value INT,
PRIMARY KEY (id),
UNIQUE KEY ui(value)) ENGINE=myisam;
insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
CREATE TABLE gap5 (
pk int primary key,
a int,
b int,
key(a)
) ENGINE=myisam;
insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
create table gap6 like gap5;
insert into gap6 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
set session gap_lock_raise_error= WARNING;
select sum(value) from gap1;
sum(value)
500500
update gap1 set gap1.value= (select count(*) from gap2);
select sum(value) from gap1;
sum(value)
1000000
drop table gap1, gap2, gap3;
set global gap_lock_raise_error= off;
drop table gap1, gap2, gap3, gap5, gap6;
1 change: 1 addition & 0 deletions mysql-test/suite/percona/t/gap_lock_error_memory.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
let $engine=memory;
let $expect_gap_lock_errors=0;
let $gap_lock_error_skip_partitioning=1;
--let $warning_or_error=WARNING
--source include/gap_lock_error_init.inc
select sum(value) from gap1;
update gap1 set gap1.value= (select count(*) from gap2);
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/percona/t/gap_lock_error_myisam.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
let $engine=myisam;
let $expect_gap_lock_errors=0;
let $gap_lock_error_skip_partitioning=1;
--let $warning_or_error=WARNING
--source include/gap_lock_error_init.inc
select sum(value) from gap1;
update gap1 set gap1.value= (select count(*) from gap2);
Expand Down
14 changes: 2 additions & 12 deletions mysql-test/suite/rocksdb/include/hermitage.inc
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ commit;

--source suite/rocksdb/include/hermitage_init.inc
connection con1;
# MyRocks does not support gap locks in REPEATABLE-READ mode, expect error
if ($trx_isolation == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
update test set value = value + 10;
connection con2;
select variable_value into @a from performance_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
Expand All @@ -127,7 +122,7 @@ if ($trx_isolation == "READ COMMITTED")
# MyRocks does not support gap locks in REPEATABLE-READ mode, expect error
if ($trx_isolation == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
--error ER_LOCK_DEADLOCK
reap;
select variable_value-@a from performance_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors';
}
Expand Down Expand Up @@ -184,11 +179,6 @@ connection con1;
select * from test where value % 5 = 0;
connection con2;

# MyRocks does not support gap locks in REPEATABLE-READ mode, expect error
if ($trx_isolation == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
update test set value = 12 where value = 10;
commit;
connection con1;
Expand All @@ -215,7 +205,7 @@ if ($trx_isolation == "READ COMMITTED")
# MyRocks does not support gap locks in REPEATABLE-READ mode, expect error
if ($trx_isolation == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
--error ER_LOCK_DEADLOCK
delete from test where value = 20;
}
commit;
Expand Down
4 changes: 0 additions & 4 deletions mysql-test/suite/rocksdb/include/locking_issues_case1_2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ connect (con2,localhost,root,,);
connection con1;
eval SET SESSION TRANSACTION ISOLATION LEVEL $isolation_level;
BEGIN;
if ($isolation_level == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
SELECT * FROM t0 WHERE id1=1 FOR UPDATE;

connection con2;
Expand Down
26 changes: 3 additions & 23 deletions mysql-test/suite/rocksdb/include/locking_issues_case2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,28 @@ if ($lock_scanned_rows == 1)
{
connection con1;
# This is expected to leave locks on all the rows in t0
# if in READ COMMITED, REPEATABLEREAD is a gap lock violation
if ($isolation_level == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
# if in READ COMMITED
SELECT * FROM t0 WHERE value > 0 FOR UPDATE;

connection con2;
if ($isolation_level == "READ COMMITTED")
{
--error ER_LOCK_WAIT_TIMEOUT
}
--error ER_LOCK_WAIT_TIMEOUT
UPDATE t0 SET VALUE=10 WHERE id=1;
}

if ($lock_scanned_rows == 0)
{
connection con1;
if ($isolation_level == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
# This is expected to release locks on rows with value=0
SELECT * FROM t0 WHERE value > 0 FOR UPDATE;

connection con2;
# This should succeed as con1 should have released the lock on row (1,0)
UPDATE t0 SET VALUE=10 WHERE id=1;

if ($isolation_level == "READ COMMITTED")
{
# This should fail because lock on row (5,1) is still held.
--error ER_LOCK_WAIT_TIMEOUT
}
--error ER_LOCK_WAIT_TIMEOUT
UPDATE t0 SET VALUE=10 WHERE id=5;

connection con1;
# Do another operation
if ($isolation_level == "REPEATABLE READ")
{
--error ER_LOCK_WAIT_TIMEOUT
}
UPDATE t0 SET value=100 WHERE id in (4,5) and value>0;

connection con2;
Expand Down
4 changes: 0 additions & 4 deletions mysql-test/suite/rocksdb/include/locking_issues_case7.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ if ($lock_scanned_rows == 0)
UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3;

connection con2;
if ($isolation_level == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
UPDATE t2 SET value=value+100;
SELECT * FROM t2;
}
Expand Down
8 changes: 0 additions & 8 deletions mysql-test/suite/rocksdb/include/transaction_isolation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ connection con1;
--sorted_result
SELECT a FROM t1; # Third snapshot

if ($trx_isolation == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
INSERT INTO t1 (a) SELECT a+100 FROM t1;

--sorted_result
Expand All @@ -67,10 +63,6 @@ SELECT a FROM t1; # Inside the transaction
# The test will have a 'logical' result for repeatable read, even although
# we currently don't have an engine which works this way.

if ($trx_isolation == "REPEATABLE READ")
{
--error ER_UNKNOWN_ERROR
}
INSERT INTO t1 (a) SELECT a+200 FROM t1;

--sorted_result
Expand Down
Loading