summaryrefslogtreecommitdiff
path: root/storage/tokudb/mysql-test/tokudb/t/i_s_tokudb_lock_waits_timeout.test
blob: 3011443fa0411e4e0684b14d60dbf1a7c9f0e18f (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
# verify that tokudb_locks and tokudb_lock_waits contents for 2 conflicting transactions with a lock timeout

source include/have_tokudb.inc;
set default_storage_engine='tokudb';
set tokudb_prelock_empty=false;
disable_warnings;
drop table if exists t;
enable_warnings;

create table t (id int primary key);

# should be empty
select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;

connect (conn_a,localhost,root,,);
set autocommit=0;
set tokudb_prelock_empty=OFF;
insert into t values (1);

connect (conn_b,localhost,root,,);
set autocommit=0;
send insert into t values (1);

# should find the presence of a lock on 1st transaction
connection default;
let $wait_condition= select count(*)=1 from information_schema.processlist where info='insert into t values (1)' and state='update';
source include/wait_condition.inc;
real_sleep 1; # delay a little to shorten the update -> write row -> lock wait race

replace_column 1 TRX_ID 2 MYSQL_ID; 
replace_result $datadir ./;
select * from information_schema.tokudb_locks;

# should find the presence of a lock_wait on the 2nd transaction
replace_column 1 REQUEST_TRX_ID 2 BLOCK_TRX_ID 6 LOCK_WAITS_START_TIME;
replace_result $datadir ./;
select * from information_schema.tokudb_lock_waits;

# should find the presence of two transactions
replace_column 1 TRX_ID 2 MYSQL_ID;
select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;

connection conn_a;
sleep 5; # sleep longer than the lock timer to force a lock timeout on txn_b
commit;

# verify that the lock on the 1st transaction is released and replaced by the lock for the 2nd transaction
replace_column 1 TRX_ID 2 MYSQL_ID;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;

connection conn_b;
--error 1205 # lock timeout
reap;
commit;

connection default;
disconnect conn_a;
disconnect conn_b;

# should be be empty
select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
select * from information_schema.tokudb_locks;
select * from information_schema.tokudb_lock_waits;

# cleanup
drop table t;