1connect  con1, localhost, root,,;
2connect  con2, localhost, root,,;
3connect  con3, localhost, root,,;
4connection default;
5set debug_sync='RESET';
6drop table if exists t1;
7create table t1 (id int, value int, primary key (id)) engine=rocksdb;
8create table t2 (id int, id2 int, value int, primary key (id), unique key (id2)) engine=rocksdb;
9connection con1;
10begin;
11insert into t1 values (1,1);
12connection con2;
13set session rocksdb_lock_wait_timeout=50;
14begin;
15insert into t1 values (1,2);
16connection con1;
17commit;
18connection con2;
19ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
20commit;
21select * from t1;
22id	value
231	1
24truncate table t1;
25connection con1;
26begin;
27insert into t2 values (1,1,1);
28connection con2;
29begin;
30insert into t2 values (2,1,2);
31connection con1;
32commit;
33connection con2;
34ERROR 23000: Duplicate entry '1' for key 'id2'
35commit;
36select * from t2;
37id	id2	value
381	1	1
39truncate table t2;
40connection con1;
41begin;
42insert into t1 values (1,1);
43connection con2;
44begin;
45insert into t1 values (1,2);
46connection con1;
47rollback;
48connection con2;
49commit;
50select * from t1;
51id	value
521	2
53truncate table t1;
54connection con1;
55begin;
56insert into t2 values (1,1,1);
57connection con2;
58begin;
59insert into t2 values (2,1,2);
60connection con1;
61rollback;
62connection con2;
63commit;
64select * from t2;
65id	id2	value
662	1	2
67truncate table t2;
68connection con1;
69set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked1 WAIT_FOR go';
70insert into t1 values (1,1);
71connection default;
72set debug_sync='now WAIT_FOR parked1';
73connection con2;
74set debug_sync='rocksdb.update_write_row_after_unique_check SIGNAL parked2 WAIT_FOR go';
75insert into t2 values (1,1,1);
76connection default;
77set debug_sync='now WAIT_FOR parked2';
78connection con3;
79set session rocksdb_lock_wait_timeout=1;
80insert into t1 values (1,2);
81ERROR HY000: Lock wait timeout exceeded; try restarting transaction
82insert into t2 values (2,1,2);
83ERROR HY000: Lock wait timeout exceeded; try restarting transaction
84connection default;
85set debug_sync='now SIGNAL go';
86connection con1;
87connection con2;
88connection default;
89insert into t1 values (1,2);
90ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
91insert into t2 values (2,1,2);
92ERROR 23000: Duplicate entry '1' for key 'id2'
93select * from t1;
94id	value
951	1
96select * from t2;
97id	id2	value
981	1	1
99connection default;
100set debug_sync='RESET';
101disconnect con1;
102disconnect con2;
103disconnect con3;
104drop table t1, t2;
105connection default;
106drop table if exists t1,t2,t3;
107create table t1 (id int, value int, primary key (id)) engine=rocksdb;
108create table t2 (id int, id2 int, value int, primary key (id), unique key (id2)) engine=rocksdb;
109create table t3 (id int, value int) engine=rocksdb;
110SET @old_val = @@session.unique_checks;
111set @@session.unique_checks = FALSE;
112insert into t1 values (1, 1), (1, 2);
113insert into t2 values (1, 1, 1), (1, 2, 1);
114ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
115insert into t3 values (1, 1), (1, 1);
116set @@session.unique_checks = @old_val;
117drop table t1, t2, t3;
118