1skip Tokudb Lock Waits not in I_S in MariaDB;
2# verify that tokudb_locks and tokudb_lock_waits contents for 2 conflicting transactions with a lock timeout
3
4source include/have_tokudb.inc;
5set default_storage_engine='tokudb';
6set tokudb_prelock_empty=false;
7disable_warnings;
8drop table if exists t;
9enable_warnings;
10
11create table t (id int primary key);
12
13# should be empty
14select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
15select * from information_schema.tokudb_locks;
16select * from information_schema.tokudb_lock_waits;
17
18connect (conn_a,localhost,root,,);
19set autocommit=0;
20set tokudb_prelock_empty=OFF;
21insert into t values (1);
22
23connect (conn_b,localhost,root,,);
24set autocommit=0;
25set tokudb_prelock_empty=OFF;
26set tokudb_lock_timeout=60000; # set lock wait timeout to 1 minute
27
28send replace into t values (1);
29
30# should find the presence of a lock on 1st transaction
31connection default;
32let $wait_condition= select count(*)=1 from information_schema.processlist where info='replace into t values (1)' and state='update';
33source include/wait_condition.inc;
34real_sleep 1; # delay a little to shorten the update -> write row -> lock wait race
35
36replace_column 1 TRX_ID 2 MYSQL_ID;
37select * from information_schema.tokudb_locks;
38
39# should find the presence of a lock_wait on the 2nd transaction
40replace_column 1 REQUEST_TRX_ID 2 BLOCK_TRX_ID 6 LOCK_WAITS_START_TIME;
41select * from information_schema.tokudb_lock_waits;
42
43# should find the presence of two transactions
44replace_column 1 TRX_ID 2 MYSQL_ID;
45select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
46
47connection conn_a;
48real_sleep 45; # sleep till we get close to timeout since wait_condidion will timeout @ 30 seconds
49let $wait_condition= select count(*)=0 from information_schema.processlist where info='replace into t values (1)' and state='update';
50source include/wait_condition.inc;
51commit;
52
53# verify that the lock on the 1st transaction is released and replaced by the lock for the 2nd transaction
54replace_column 1 TRX_ID 2 MYSQL_ID;
55select * from information_schema.tokudb_locks;
56select * from information_schema.tokudb_lock_waits;
57
58connection conn_b;
59--error 1205 # lock timeout
60reap;
61commit;
62
63connection default;
64disconnect conn_a;
65disconnect conn_b;
66
67# should be be empty
68select trx_id,trx_mysql_thread_id from information_schema.tokudb_trx;
69select * from information_schema.tokudb_locks;
70select * from information_schema.tokudb_lock_waits;
71
72# cleanup
73drop table t;
74