Skip to content

Commit d47814d

Browse files
PS-10098 Configurable Gap Lock Detection for MyRocks
1 parent f629286 commit d47814d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+460
-1280
lines changed

mysql-test/include/gap_lock_error_all.inc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--let $warning_or_error= ERROR
12
--source include/gap_lock_error_init.inc
23

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

21-
let $autocommit = 0;
22-
--source include/gap_lock_error_update.inc
23-
let $autocommit = 1;
2422
--source include/gap_lock_error_update.inc
25-
2623
--source include/gap_lock_error_cleanup.inc
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
drop table gap1, gap2, gap3;
1+
set global gap_lock_raise_error= off;
2+
3+
drop table gap1, gap2, gap3, gap5, gap6;
24
if (!$gap_lock_error_skip_partitioning) {
35
drop table gap4;
46
}

mysql-test/include/gap_lock_error_init.inc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# ==== Usage ====
2+
#
3+
# [--let $warning_or_error= WARNING | ERROR ]
4+
# --source include/assert_no_warnings.inc
5+
#
6+
# Parameters:
7+
#
8+
# $warning_or_error
9+
# Whether we are expected to raise warning or error.
10+
#
11+
12+
--disable_warnings
13+
drop table if exists gap1,gap2,gap3;
14+
--enable_warnings
15+
116
eval CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
217
PRIMARY KEY (id1, id2, id3),
318
INDEX i (c1)) ENGINE=$engine;
@@ -23,6 +38,19 @@ while ($i <= $max) {
2338
--enable_query_log
2439

2540
insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
41+
2642
if (!$gap_lock_error_skip_partitioning) {
2743
insert into gap4 values (1,1), (2,2),(3,3),(4,4),(5,5);
2844
}
45+
46+
eval CREATE TABLE gap5 (
47+
pk int primary key,
48+
a int,
49+
b int,
50+
key(a)
51+
) ENGINE=$engine;
52+
insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
53+
create table gap6 like gap5;
54+
insert into gap6 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
55+
56+
eval set session gap_lock_raise_error= $warning_or_error;

mysql-test/include/gap_lock_error_select.inc

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
eval set session autocommit=$autocommit;
2-
let $is_gaplock_target = `SELECT @@autocommit = 0 && '$select_lock' != '' && '$expect_gap_lock_errors' = 1`;
2+
let $is_gaplock_target = `SELECT @@autocommit = 0 && '$select_lock' != ''`;
33

44
if ($is_gaplock_target)
55
{
@@ -49,12 +49,6 @@ eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
4949
eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
5050
order by c1 $select_lock;
5151
eval select * from gap3 where id=1 $select_lock;
52-
eval select * from gap4 where id=1 $select_lock;
53-
eval select * from gap4 where id in (1, 2, 3) $select_lock;
54-
--error ER_UNKNOWN_ERROR
55-
eval select * from gap4 $select_lock;
56-
--error ER_UNKNOWN_ERROR
57-
eval select * from gap4 where id between 3 and 7 $select_lock;
5852
}
5953

6054
if (!$is_gaplock_target)
@@ -82,8 +76,4 @@ eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
8276
eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
8377
order by c1 $select_lock;
8478
eval select * from gap3 where id=1 $select_lock;
85-
eval select * from gap4 where id=1 $select_lock;
86-
eval select * from gap4 where id in (1, 2, 3) $select_lock;
87-
eval select * from gap4 $select_lock;
88-
eval select * from gap4 where id between 3 and 7 $select_lock;
8979
}

mysql-test/include/gap_lock_error_update.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ eval create table u1(
6363
primary key (c1, c2, c3),
6464
unique key (c3, c1)
6565
) engine=$engine;
66+
set session gap_lock_raise_error=error;
6667
begin;
6768
insert into u1 values (1,1,1,1);
6869
commit;

mysql-test/r/all_persisted_variables.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ include/assert.inc [Expect 500+ variables in the table. Due to open Bugs, we are
4747

4848
# Test SET PERSIST
4949

50-
include/assert.inc [Expect 489 persisted variables in the table.]
50+
include/assert.inc [Expect 490 persisted variables in the table.]
5151

5252
************************************************************
5353
* 3. Restart server, it must preserve the persisted variable
5454
* settings. Verify persisted configuration.
5555
************************************************************
5656
# restart
5757

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

6262
************************************************************
6363
* 4. Test RESET PERSIST IF EXISTS. Verify persisted variable

mysql-test/r/mysqld--help-notwin.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ The following options may be given as the first argument:
423423
word symbols for full text search queries
424424
--ft-stopword-file=name
425425
Use stopwords from this file instead of built-in list
426+
--gap-lock-raise-error[=name]
427+
Controls raising a warning or an error when executing
428+
queries that rely on Gap Lock. It can take the following
429+
values: OFF: no error is raised WARNING: a warning is
430+
raised ERROR: an error is raised. Default is OFF
426431
--gdb Set up signals usable for debugging.
427432
--general-log Log connections and queries to a table or log file.
428433
Defaults to logging to a file hostname.log, or if
@@ -1847,6 +1852,7 @@ ft-min-word-len 4
18471852
ft-query-expansion-limit 20
18481853
ft-query-extra-word-chars FALSE
18491854
ft-stopword-file (No default value)
1855+
gap-lock-raise-error OFF
18501856
gdb FALSE
18511857
general-log FALSE
18521858
generated-random-password-length 20
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
drop table if exists gap1,gap2,gap3;
12
CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
23
PRIMARY KEY (id1, id2, id3),
34
INDEX i (c1)) ENGINE=memory;
@@ -6,11 +7,22 @@ CREATE TABLE gap3 (id INT, value INT,
67
PRIMARY KEY (id),
78
UNIQUE KEY ui(value)) ENGINE=memory;
89
insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
10+
CREATE TABLE gap5 (
11+
pk int primary key,
12+
a int,
13+
b int,
14+
key(a)
15+
) ENGINE=memory;
16+
insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
17+
create table gap6 like gap5;
18+
insert into gap6 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
19+
set session gap_lock_raise_error= WARNING;
920
select sum(value) from gap1;
1021
sum(value)
1122
500500
1223
update gap1 set gap1.value= (select count(*) from gap2);
1324
select sum(value) from gap1;
1425
sum(value)
1526
1000000
16-
drop table gap1, gap2, gap3;
27+
set global gap_lock_raise_error= off;
28+
drop table gap1, gap2, gap3, gap5, gap6;
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
drop table if exists gap1,gap2,gap3;
12
CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
23
PRIMARY KEY (id1, id2, id3),
34
INDEX i (c1)) ENGINE=myisam;
@@ -6,11 +7,22 @@ CREATE TABLE gap3 (id INT, value INT,
67
PRIMARY KEY (id),
78
UNIQUE KEY ui(value)) ENGINE=myisam;
89
insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
10+
CREATE TABLE gap5 (
11+
pk int primary key,
12+
a int,
13+
b int,
14+
key(a)
15+
) ENGINE=myisam;
16+
insert into gap5 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
17+
create table gap6 like gap5;
18+
insert into gap6 values (1,1,1), (2,2,2), (3,3,3), (4,4,4);
19+
set session gap_lock_raise_error= WARNING;
920
select sum(value) from gap1;
1021
sum(value)
1122
500500
1223
update gap1 set gap1.value= (select count(*) from gap2);
1324
select sum(value) from gap1;
1425
sum(value)
1526
1000000
16-
drop table gap1, gap2, gap3;
27+
set global gap_lock_raise_error= off;
28+
drop table gap1, gap2, gap3, gap5, gap6;

mysql-test/suite/percona/t/gap_lock_error_memory.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
let $engine=memory;
44
let $expect_gap_lock_errors=0;
55
let $gap_lock_error_skip_partitioning=1;
6+
--let $warning_or_error=WARNING
67
--source include/gap_lock_error_init.inc
78
select sum(value) from gap1;
89
update gap1 set gap1.value= (select count(*) from gap2);

0 commit comments

Comments
 (0)