summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb/t/drop_table2.test
blob: a9012aea80a10d541c3c4e67534cee65f9f53626 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--source include/have_rocksdb.inc

call mtr.add_suppression("Column family 'cf1' not found");
call mtr.add_suppression("Column family 'rev:cf2' not found");

--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
DROP TABLE IF EXISTS t4;
DROP TABLE IF EXISTS t5;
--enable_warnings

call mtr.add_suppression("Column family 'cf1' not found");
call mtr.add_suppression("Column family 'rev:cf2' not found");

# Start from clean slate
set global rocksdb_compact_cf = 'cf1';
set global rocksdb_compact_cf = 'rev:cf2';
set global rocksdb_signal_drop_index_thread = 1;
--source include/restart_mysqld.inc

CREATE TABLE t1 (
  a int not null,
  b int not null,
  primary key (a,b) comment 'cf1',
  key (b) comment 'rev:cf2'
) ENGINE=RocksDB;

CREATE TABLE t2 (
  a int not null,
  b int not null,
  primary key (a,b) comment 'cf1',
  key (b) comment 'rev:cf2'
) ENGINE=RocksDB;

CREATE TABLE t3 (
  a int not null,
  b int not null,
  primary key (a,b) comment 'cf1',
  key (b) comment 'rev:cf2'
) ENGINE=RocksDB;

CREATE TABLE t4 (
  a int not null,
  b int not null,
  primary key (a,b) comment 'cf1',
  key (b) comment 'rev:cf2'
) ENGINE=RocksDB;

# Populate tables
let $max = 1000;
let $table = t1;
--source drop_table_repopulate_table.inc
let $table = t2;
--source drop_table_repopulate_table.inc
let $table = t3;
--source drop_table_repopulate_table.inc
let $table = t4;
--source drop_table_repopulate_table.inc


# Restart the server before t2's indices are deleted
--source include/restart_mysqld.inc

let $table = t1;
--source drop_table_repopulate_table.inc
let $table = t4;
--source drop_table_repopulate_table.inc


# Insert enough data to trigger compactions that eliminate t2 and t3
let $max = 50000;
let $table = t1;
--source drop_table_repopulate_table.inc
let $table = t4;
--source drop_table_repopulate_table.inc


# Restart the server before t4's indices are deleted
--source include/restart_mysqld.inc

# Make sure new table gets unique indices
CREATE TABLE t5 (
  a int not null,
  b int not null,
  primary key (a,b) comment 'cf1',
  key (b) comment 'rev:cf2'
) ENGINE=RocksDB;

let $max = 1000;
let $table = t5;
--source drop_table_repopulate_table.inc

set @@global.rocksdb_compact_cf = 'cf1';
set @@global.rocksdb_compact_cf = 'rev:cf2';
set @@global.rocksdb_compact_cf = 'default';

perl;
$size+=-s $_ for (<$ENV{MYSQLTEST_VARDIR}/mysqld.1/data/\#rocksdb/*.sst>);
$filename= "$ENV{MYSQLTEST_VARDIR}/tmp/size_output";
open(F, '>', $filename) || die("Can't open file $filename: $!");
print F $size;
EOF
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;

set @@global.rocksdb_compact_cf = 'cf1';
set @@global.rocksdb_compact_cf = 'rev:cf2';
set @@global.rocksdb_compact_cf = 'default';

let $show_rpl_debug_info= 1; # to force post-failure printout
let $wait_timeout= 300; # Override default 30 seconds with 300.
let $wait_condition = select count(*) = 0 
                      as c from information_schema.rocksdb_global_info
                      where TYPE = 'DDL_DROP_INDEX_ONGOING';
--source include/wait_condition.inc

# Check that space is reclaimed
perl;
$size+=-s $_ for (<$ENV{MYSQLTEST_VARDIR}/mysqld.1/data/\#rocksdb/*.sst>);
$filename= "$ENV{MYSQLTEST_VARDIR}/tmp/size_output";
open(F, '<', $filename) || die("Can't open file $filename: $!");
$old=<F>;
print "Compacted\n" if $old > $size * 2;
EOF

# Cleanup