summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb/t/optimize_myrocks_replace_into_lock.test
blob: 6cce429a5de767dc912570e420039f02f70a055b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
--source include/have_rocksdb.inc
--source include/have_debug.inc

# Enable blind replace
SET GLOBAL enable_blind_replace=ON;

connect (con1,localhost,root,,);
connect (con2,localhost,root,,);

create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

#
# case 1: update is blocked by replace into 
#
connection con1;
SELECT @@global.enable_blind_replace;
begin;
replace into t1 values(1,11);


connection con2;
SELECT @@global.enable_blind_replace;
begin;
send update t1 set c2=22 where c1=1;


connection default;
# Check that the above update is blocked
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
    where state = 'Waiting for row lock' and
          info = 'update t1 set c2=22 where c1=1';
--source include/wait_condition.inc


connection con1;
commit;

connection con2;
--echo # Reap update.
--reap
commit;
select * from t1;


#
# cast 2: replace into is blocked by update
#

connection con1;
SELECT @@global.enable_blind_replace;
begin;
update t1 set c2=55 where c1=1;

connection con2;
SELECT @@global.enable_blind_replace;
begin;
send replace into t1 values(1,66);


connection default;
# Check that the above replace into is blocked
let $wait_condition=
  select count(*) = 1 from information_schema.processlist
    where state = 'Waiting for row lock' and
          info = 'replace into t1 values(1,66)';
--source include/wait_condition.inc


connection con1;
commit;

connection con2;
--echo # Reap replace into.
--reap
commit;
select * from t1;

connection default;
drop table t1;

disconnect con1;
disconnect con2;

# Disable blind replace
SET GLOBAL enable_blind_replace=DEFAULT;