summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test
blob: d91d54a3543773fd51e3fa6deb3cbd9f0f3fded5 (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
132
133
134
135
136
137
138
139
--source include/have_rocksdb.inc
--source include/have_log_bin.inc
--source include/not_windows.inc
--echo # Disable for valgrind because this takes too long
--source include/not_valgrind.inc

--disable_warnings
DROP DATABASE IF EXISTS mysqlslap;
--enable_warnings

CREATE DATABASE mysqlslap;
USE mysqlslap;
CREATE TABLE t1(id BIGINT AUTO_INCREMENT, value BIGINT, PRIMARY KEY(id)) ENGINE=rocksdb;

SET @save_rocksdb_enable_2pc= @@rocksdb_enable_2pc;
SET @save_rocksdb_flush_log_at_trx_commit= @@rocksdb_flush_log_at_trx_commit;

#
# In MariaDB, regular group commit operation does not cause increment of
# rocksdb_wal_group_syncs. 
# 

--echo # 2PC enabled, MyRocks durability enabled
SET GLOBAL rocksdb_enable_2pc=1;
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;

--echo ## 
--echo ## 2PC + durability + single thread
--echo ## 
select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
--exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"
select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1 = 1000) as Binlog_commits 
from information_schema.global_status where variable_name='Binlog_commits';
select IF(variable_value - @b2 = 1000, 'OK', variable_value - @b2 = 1000) as Binlog_group_commits 
from information_schema.global_status where variable_name='Binlog_group_commits';
--echo # Prepare operations sync, commits don't. We expect slightly more than 1K syncs:
select IF(variable_value - @b3 between 1000 and 1500, 'OK', variable_value - @b3 between 1000 and 1500) as Rocksdb_wal_synced 
from information_schema.global_status where variable_name='Rocksdb_wal_synced';

--echo ## 
--echo ## 2PC + durability + group commit
--echo ## 
select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';

--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"

select IF(variable_value - @b1 = 10000, 'OK', variable_value - @b1 = 10000) as Binlog_commits 
from information_schema.global_status where variable_name='Binlog_commits';
select IF(variable_value - @b2 between 100 and 5000, 'OK', variable_value - @b2 between 100 and 5000) as Binlog_group_commits 
from information_schema.global_status where variable_name='Binlog_group_commits';
select IF(variable_value - @b3 between 1 and 9000, 'OK', variable_value - @b3 between 1 and 9000)
from information_schema.global_status where variable_name='Rocksdb_wal_synced';

--echo ## 
--echo # 2PC enabled, MyRocks durability disabled, single thread
--echo ## 
SET GLOBAL rocksdb_enable_2pc=1;
SET GLOBAL rocksdb_flush_log_at_trx_commit=0;

select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
--exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"

select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1 = 1000) as Binlog_commits 
from information_schema.global_status where variable_name='Binlog_commits';
select IF(variable_value - @b2 = 1000, 'OK', variable_value - @b2 = 1000) as Binlog_group_commits 
from information_schema.global_status where variable_name='Binlog_group_commits';
select IF(variable_value - @b3 < 10, 'OK', variable_value - @b3 < 10)
from information_schema.global_status where variable_name='Rocksdb_wal_synced';

--echo ## 
--echo # 2PC enabled, MyRocks durability disabled, concurrent workload
--echo ## 

select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';

--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"

select IF(variable_value - @b1 = 10000, 'OK', variable_value - @b1 = 10000) as Binlog_commits 
from information_schema.global_status where variable_name='Binlog_commits';
select IF(variable_value - @b2 < 8000, 'OK', variable_value - @b2 < 8000) as Binlog_group_commits 
from information_schema.global_status where variable_name='Binlog_group_commits';
select IF(variable_value - @b3 < 10, 'OK', variable_value - @b3 < 10)
from information_schema.global_status where variable_name='Rocksdb_wal_synced';

## 
## The next two are disabled because they don't add any test coverage in
## MariaDB. @@rocksdb_enable_2pc=0 is a MyRocks-internal setting, binlog
##  [group] commit still happens, and syncing RocksDB WAL too.
##

--disable_parsing
--echo ##
--echo # 2PC disabled, MyRocks durability enabled, one thread
--echo ##
SET GLOBAL rocksdb_enable_2pc=0;
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;

select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';

--exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"

select variable_value - @b1 as Binlog_commits 
from information_schema.global_status where variable_name='Binlog_commits';
select variable_value - @b2  as Binlog_group_commits 
from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value - @b3 as Rocksdb_wal_synced
from information_schema.global_status where variable_name='Rocksdb_wal_synced';

--echo ##
--echo # 2PC disabled, MyRocks durability enabled, concurrent workload
--echo ##
select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits';
select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced';
--exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)"

select variable_value - @b1 as Binlog_commits 
from information_schema.global_status where variable_name='Binlog_commits';
select variable_value - @b2  as Binlog_group_commits 
from information_schema.global_status where variable_name='Binlog_group_commits';
select variable_value - @b3 as Rocksdb_wal_synced
from information_schema.global_status where variable_name='Rocksdb_wal_synced';
--enable_parsing

SET GLOBAL rocksdb_enable_2pc= @save_rocksdb_enable_2pc;
SET GLOBAL rocksdb_flush_log_at_trx_commit= @save_rocksdb_flush_log_at_trx_commit;

DROP TABLE t1;
DROP DATABASE mysqlslap;