1--source include/have_rocksdb.inc
2call mtr.add_suppression("Column family 'cf1' not found");
3call mtr.add_suppression("Column family 'rev:cf2' not found");
4
5--disable_warnings
6DROP TABLE IF EXISTS t1;
7DROP TABLE IF EXISTS t2;
8DROP TABLE IF EXISTS t3;
9DROP TABLE IF EXISTS t4;
10DROP TABLE IF EXISTS t5;
11--enable_warnings
12
13call mtr.add_suppression("Column family 'cf1' not found");
14call mtr.add_suppression("Column family 'rev:cf2' not found");
15call mtr.add_suppression("LibRocksDB");
16
17# Start from clean slate
18set global rocksdb_compact_cf = 'cf1';
19set global rocksdb_compact_cf = 'rev:cf2';
20set global rocksdb_signal_drop_index_thread = 1;
21--source include/restart_mysqld.inc
22
23CREATE TABLE t1 (
24  a int not null,
25  b int not null,
26  primary key (a,b) comment 'cf1',
27  key (b) comment 'rev:cf2'
28) ENGINE=RocksDB;
29
30CREATE TABLE t2 (
31  a int not null,
32  b int not null,
33  primary key (a,b) comment 'cf1',
34  key (b) comment 'rev:cf2'
35) ENGINE=RocksDB;
36
37CREATE TABLE t3 (
38  a int not null,
39  b int not null,
40  primary key (a,b) comment 'cf1',
41  key (b) comment 'rev:cf2'
42) ENGINE=RocksDB;
43
44CREATE TABLE t4 (
45  a int not null,
46  b int not null,
47  primary key (a,b) comment 'cf1',
48  key (b) comment 'rev:cf2'
49) ENGINE=RocksDB;
50
51# Populate tables
52let $max = 1000;
53let $table = t1;
54--source drop_table_repopulate_table.inc
55let $table = t2;
56--source drop_table_repopulate_table.inc
57let $table = t3;
58--source drop_table_repopulate_table.inc
59let $table = t4;
60--source drop_table_repopulate_table.inc
61
62drop table t2;
63
64# Restart the server before t2's indices are deleted
65--source include/restart_mysqld.inc
66
67let $table = t1;
68--source drop_table_repopulate_table.inc
69let $table = t4;
70--source drop_table_repopulate_table.inc
71
72drop table t3;
73
74# Insert enough data to trigger compactions that eliminate t2 and t3
75let $max = 50000;
76let $table = t1;
77--source drop_table_repopulate_table.inc
78let $table = t4;
79--source drop_table_repopulate_table.inc
80
81# Run manual compaction, then restarting mysqld
82# and confirming it is not blocked.
83SET GLOBAL rocksdb_max_manual_compactions = 2;
84SET GLOBAL rocksdb_debug_manual_compaction_delay = 3600;
85connect (con1, localhost, root,,);
86connect (con2, localhost, root,,);
87connect (con3, localhost, root,,);
88connection con1;
89send SET GLOBAL rocksdb_compact_cf='cf1';
90connection con2;
91send SET GLOBAL rocksdb_compact_cf='rev:cf2';
92connection default;
93let $wait_condition = select count(*) = 2 from information_schema.processlist where info like 'SET GLOBAL rocksdb_compact_cf%';
94--source include/wait_condition.inc
95# longer enough than manual compaction thread to start compaction
96--sleep 2
97select * from information_schema.global_status where variable_name='rocksdb_manual_compactions_running';
98
99connection con3;
100--error ER_INTERNAL_ERROR
101SET GLOBAL rocksdb_compact_cf='cf1';
102--error ER_INTERNAL_ERROR
103SET GLOBAL rocksdb_compact_cf='rev:cf2';
104
105connection default;
106--source include/restart_mysqld.inc
107
108drop table t4;
109
110# Restart the server before t4's indices are deleted
111--source include/restart_mysqld.inc
112
113# Make sure new table gets unique indices
114CREATE TABLE t5 (
115  a int not null,
116  b int not null,
117  primary key (a,b) comment 'cf1',
118  key (b) comment 'rev:cf2'
119) ENGINE=RocksDB;
120
121let $max = 1000;
122let $table = t5;
123--source drop_table_repopulate_table.inc
124
125drop table t5;
126
127# Manually compact column families, cleaning up all lingering data
128set global rocksdb_compact_cf = 'cf1';
129set global rocksdb_compact_cf = 'rev:cf2';
130
131# Signal thread to check for dropped indices
132set global rocksdb_signal_drop_index_thread = 1;
133
134let $show_rpl_debug_info= 1; # to force post-failure printout
135let $wait_timeout= 300; # Override default 30 seconds with 300.
136let $wait_condition = select count(*) = 0
137                      as c from information_schema.rocksdb_global_info
138                      where TYPE = 'DDL_DROP_INDEX_ONGOING';
139--source include/wait_condition.inc
140
141## Upstream has removed the following:
142--disable_parsing
143--enable_parsing
144# Cleanup
145drop table t1;
146