Skip to content

Commit 8b97349

Browse files
alxyangfacebook-github-bot
authored andcommitted
use new FlushWAL API in MyRocks
Summary: RocksDB has recently added a FlushWAL API which will improve upon the performance of MySQL 2PC (more details here facebook/rocksdb#2345). This patch adds support for using the FlushWAL API in MyRocks and also matches flush_log_at_trx_commit with innodb_flush_log_at_trx_commit behaviour. Finally, it updates the submodule to include the removal of an unneeded assertion in the write path, which was tripped by this change. Reviewed By: yoshinorim Differential Revision: D5503719 fbshipit-source-id: c29f0a2
1 parent 0df4bd5 commit 8b97349

12 files changed

+158
-47
lines changed

Diff for: mysql-test/r/mysqld--help-notwin-profiling.result

+8
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,9 @@ The following options may be given as the first argument:
11471147
Enable or disable ROCKSDB_COMPACTION_STATS plugin.
11481148
Possible values are ON, OFF, FORCE (don't start if the
11491149
plugin fails to load).
1150+
--rocksdb-concurrent-prepare
1151+
DBOptions::concurrent_prepare for RocksDB
1152+
(Defaults to on; use --skip-rocksdb-concurrent-prepare to disable.)
11501153
--rocksdb-create-checkpoint=name
11511154
Checkpoint directory
11521155
--rocksdb-create-if-missing
@@ -1285,6 +1288,9 @@ The following options may be given as the first argument:
12851288
DBOptions::log_file_time_to_roll for RocksDB
12861289
--rocksdb-manifest-preallocation-size=#
12871290
DBOptions::manifest_preallocation_size for RocksDB
1291+
--rocksdb-manual-wal-flush
1292+
DBOptions::manual_wal_flush for RocksDB
1293+
(Defaults to on; use --skip-rocksdb-manual-wal-flush to disable.)
12881294
--rocksdb-master-skip-tx-api
12891295
Skipping holding any lock on row access. Not effective on
12901296
slave.
@@ -2077,6 +2083,7 @@ rocksdb-compaction-sequential-deletes-count-sd FALSE
20772083
rocksdb-compaction-sequential-deletes-file-size 0
20782084
rocksdb-compaction-sequential-deletes-window 0
20792085
rocksdb-compaction-stats ON
2086+
rocksdb-concurrent-prepare TRUE
20802087
rocksdb-create-checkpoint
20812088
rocksdb-create-if-missing TRUE
20822089
rocksdb-create-missing-column-families FALSE
@@ -2120,6 +2127,7 @@ rocksdb-lock-wait-timeout 1
21202127
rocksdb-locks ON
21212128
rocksdb-log-file-time-to-roll 0
21222129
rocksdb-manifest-preallocation-size 4194304
2130+
rocksdb-manual-wal-flush TRUE
21232131
rocksdb-master-skip-tx-api FALSE
21242132
rocksdb-max-background-jobs 2
21252133
rocksdb-max-log-file-size 0

Diff for: mysql-test/r/mysqld--help-notwin.result

+8
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,9 @@ The following options may be given as the first argument:
11451145
Enable or disable ROCKSDB_COMPACTION_STATS plugin.
11461146
Possible values are ON, OFF, FORCE (don't start if the
11471147
plugin fails to load).
1148+
--rocksdb-concurrent-prepare
1149+
DBOptions::concurrent_prepare for RocksDB
1150+
(Defaults to on; use --skip-rocksdb-concurrent-prepare to disable.)
11481151
--rocksdb-create-checkpoint=name
11491152
Checkpoint directory
11501153
--rocksdb-create-if-missing
@@ -1283,6 +1286,9 @@ The following options may be given as the first argument:
12831286
DBOptions::log_file_time_to_roll for RocksDB
12841287
--rocksdb-manifest-preallocation-size=#
12851288
DBOptions::manifest_preallocation_size for RocksDB
1289+
--rocksdb-manual-wal-flush
1290+
DBOptions::manual_wal_flush for RocksDB
1291+
(Defaults to on; use --skip-rocksdb-manual-wal-flush to disable.)
12861292
--rocksdb-master-skip-tx-api
12871293
Skipping holding any lock on row access. Not effective on
12881294
slave.
@@ -2074,6 +2080,7 @@ rocksdb-compaction-sequential-deletes-count-sd FALSE
20742080
rocksdb-compaction-sequential-deletes-file-size 0
20752081
rocksdb-compaction-sequential-deletes-window 0
20762082
rocksdb-compaction-stats ON
2083+
rocksdb-concurrent-prepare TRUE
20772084
rocksdb-create-checkpoint
20782085
rocksdb-create-if-missing TRUE
20792086
rocksdb-create-missing-column-families FALSE
@@ -2117,6 +2124,7 @@ rocksdb-lock-wait-timeout 1
21172124
rocksdb-locks ON
21182125
rocksdb-log-file-time-to-roll 0
21192126
rocksdb-manifest-preallocation-size 4194304
2127+
rocksdb-manual-wal-flush TRUE
21202128
rocksdb-master-skip-tx-api FALSE
21212129
rocksdb-max-background-jobs 2
21222130
rocksdb-max-log-file-size 0

Diff for: mysql-test/suite/rocksdb/r/2pc_group_commit.result

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ CREATE DATABASE mysqlslap;
44
USE mysqlslap;
55
CREATE TABLE t1(id BIGINT AUTO_INCREMENT, value BIGINT, PRIMARY KEY(id)) ENGINE=rocksdb;
66
# 2PC enabled, MyRocks durability enabled
7-
SET GLOBAL rocksdb_enable_2pc=0;
7+
SET GLOBAL rocksdb_enable_2pc=1;
88
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
99
## 2PC + durability + single thread
1010
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
1111
select case when variable_value-@c = 1000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
1212
case when variable_value-@c = 1000 then 'true' else 'false' end
13-
false
13+
true
1414
## 2PC + durability + group commit
1515
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
1616
select case when variable_value-@c > 0 and variable_value-@c < 10000 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
1717
case when variable_value-@c > 0 and variable_value-@c < 10000 then 'true' else 'false' end
18-
false
18+
true
1919
# 2PC enabled, MyRocks durability disabled
20-
SET GLOBAL rocksdb_enable_2pc=0;
20+
SET GLOBAL rocksdb_enable_2pc=1;
2121
SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
2222
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
2323
select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
@@ -28,16 +28,16 @@ select case when variable_value-@c = 0 then 'true' else 'false' end from informa
2828
case when variable_value-@c = 0 then 'true' else 'false' end
2929
true
3030
# 2PC disabled, MyRocks durability enabled
31-
SET GLOBAL rocksdb_enable_2pc=1;
31+
SET GLOBAL rocksdb_enable_2pc=0;
3232
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
3333
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
3434
select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
3535
case when variable_value-@c = 0 then 'true' else 'false' end
36-
false
36+
true
3737
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
3838
select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
3939
case when variable_value-@c = 0 then 'true' else 'false' end
40-
false
40+
true
4141
SET GLOBAL rocksdb_enable_2pc=1;
4242
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
4343
DROP TABLE t1;

Diff for: mysql-test/suite/rocksdb/r/rocksdb.result

+2
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ rocksdb_compaction_sequential_deletes 0
880880
rocksdb_compaction_sequential_deletes_count_sd OFF
881881
rocksdb_compaction_sequential_deletes_file_size 0
882882
rocksdb_compaction_sequential_deletes_window 0
883+
rocksdb_concurrent_prepare ON
883884
rocksdb_create_checkpoint
884885
rocksdb_create_if_missing ON
885886
rocksdb_create_missing_column_families OFF
@@ -917,6 +918,7 @@ rocksdb_lock_scanned_rows OFF
917918
rocksdb_lock_wait_timeout 1
918919
rocksdb_log_file_time_to_roll 0
919920
rocksdb_manifest_preallocation_size 4194304
921+
rocksdb_manual_wal_flush ON
920922
rocksdb_master_skip_tx_api OFF
921923
rocksdb_max_background_jobs 2
922924
rocksdb_max_log_file_size 0

Diff for: mysql-test/suite/rocksdb/r/write_sync.result

+8-17
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,26 @@ SET GLOBAL rocksdb_write_disable_wal=false;
22
SET GLOBAL rocksdb_write_ignore_missing_column_families=true;
33
create table aaa (id int primary key, i int) engine rocksdb;
44
set @save_rocksdb_flush_log_at_trx_commit=@@global.rocksdb_flush_log_at_trx_commit;
5-
SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
5+
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
66
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
77
insert aaa(id, i) values(1,1);
88
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
99
variable_value-@a
10-
0
11-
insert aaa(id, i) values(2,1);
12-
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
13-
variable_value-@a
14-
0
15-
insert aaa(id, i) values(3,1);
16-
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
17-
variable_value-@a
18-
0
19-
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
20-
insert aaa(id, i) values(4,1);
21-
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
22-
variable_value-@a
2310
1
24-
insert aaa(id, i) values(5,1);
11+
insert aaa(id, i) values(2,1);
2512
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
2613
variable_value-@a
2714
2
28-
insert aaa(id, i) values(6,1);
15+
insert aaa(id, i) values(3,1);
2916
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
3017
variable_value-@a
3118
3
19+
SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
20+
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
21+
insert aaa(id, i) values(4,1);
3222
SET GLOBAL rocksdb_flush_log_at_trx_commit=2;
33-
insert aaa(id, i) values(7,1);
23+
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
24+
insert aaa(id, i) values(5,1);
3425
truncate table aaa;
3526
drop table aaa;
3627
set @@global.rocksdb_flush_log_at_trx_commit=@save_rocksdb_flush_log_at_trx_commit;

Diff for: mysql-test/suite/rocksdb/t/2pc_group_commit.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ USE mysqlslap;
1313
CREATE TABLE t1(id BIGINT AUTO_INCREMENT, value BIGINT, PRIMARY KEY(id)) ENGINE=rocksdb;
1414

1515
--echo # 2PC enabled, MyRocks durability enabled
16-
SET GLOBAL rocksdb_enable_2pc=0;
16+
SET GLOBAL rocksdb_enable_2pc=1;
1717
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
1818

1919
--echo ## 2PC + durability + single thread
@@ -28,7 +28,7 @@ select case when variable_value-@c > 0 and variable_value-@c < 10000 then 'true'
2828

2929

3030
--echo # 2PC enabled, MyRocks durability disabled
31-
SET GLOBAL rocksdb_enable_2pc=0;
31+
SET GLOBAL rocksdb_enable_2pc=1;
3232
SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
3333

3434
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';
@@ -41,7 +41,7 @@ select case when variable_value-@c = 0 then 'true' else 'false' end from informa
4141

4242

4343
--echo # 2PC disabled, MyRocks durability enabled
44-
SET GLOBAL rocksdb_enable_2pc=1;
44+
SET GLOBAL rocksdb_enable_2pc=0;
4545
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
4646

4747
select variable_value into @c from information_schema.global_status where variable_name='rocksdb_wal_group_syncs';

Diff for: mysql-test/suite/rocksdb/t/write_sync.test

+13-10
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ SET GLOBAL rocksdb_write_ignore_missing_column_families=true;
66
create table aaa (id int primary key, i int) engine rocksdb;
77

88
set @save_rocksdb_flush_log_at_trx_commit=@@global.rocksdb_flush_log_at_trx_commit;
9-
SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
10-
--exec sleep 30
9+
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
10+
--exec sleep 5
1111
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
1212
insert aaa(id, i) values(1,1);
1313
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
@@ -16,19 +16,22 @@ select variable_value-@a from information_schema.global_status where variable_na
1616
insert aaa(id, i) values(3,1);
1717
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
1818

19-
SET GLOBAL rocksdb_flush_log_at_trx_commit=1;
19+
SET GLOBAL rocksdb_flush_log_at_trx_commit=0;
20+
--exec sleep 5
21+
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
2022
insert aaa(id, i) values(4,1);
21-
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
22-
insert aaa(id, i) values(5,1);
23-
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
24-
insert aaa(id, i) values(6,1);
25-
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_wal_synced';
23+
24+
let $status_var=rocksdb_wal_synced;
25+
let $status_var_value=`select @a+1`;
26+
source include/wait_for_status_var.inc;
2627

2728
SET GLOBAL rocksdb_flush_log_at_trx_commit=2;
28-
insert aaa(id, i) values(7,1);
29+
--exec sleep 5
30+
select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced';
31+
insert aaa(id, i) values(5,1);
2932

3033
let $status_var=rocksdb_wal_synced;
31-
let $status_var_value=`select @a+4`;
34+
let $status_var_value=`select @a+1`;
3235
source include/wait_for_status_var.inc;
3336

3437
truncate table aaa;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
2+
INSERT INTO valid_values VALUES(1);
3+
INSERT INTO valid_values VALUES(1024);
4+
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
5+
INSERT INTO invalid_values VALUES('\'aaa\'');
6+
SET @start_global_value = @@global.ROCKSDB_CONCURRENT_PREPARE;
7+
SELECT @start_global_value;
8+
@start_global_value
9+
1
10+
"Trying to set variable @@global.ROCKSDB_CONCURRENT_PREPARE to 444. It should fail because it is readonly."
11+
SET @@global.ROCKSDB_CONCURRENT_PREPARE = 444;
12+
ERROR HY000: Variable 'rocksdb_concurrent_prepare' is a read only variable
13+
DROP TABLE valid_values;
14+
DROP TABLE invalid_values;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
2+
INSERT INTO valid_values VALUES(1);
3+
INSERT INTO valid_values VALUES(1024);
4+
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
5+
INSERT INTO invalid_values VALUES('\'aaa\'');
6+
SET @start_global_value = @@global.ROCKSDB_MANUAL_WAL_FLUSH;
7+
SELECT @start_global_value;
8+
@start_global_value
9+
1
10+
"Trying to set variable @@global.ROCKSDB_MANUAL_WAL_FLUSH to 444. It should fail because it is readonly."
11+
SET @@global.ROCKSDB_MANUAL_WAL_FLUSH = 444;
12+
ERROR HY000: Variable 'rocksdb_manual_wal_flush' is a read only variable
13+
DROP TABLE valid_values;
14+
DROP TABLE invalid_values;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--source include/have_rocksdb.inc
2+
3+
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
4+
INSERT INTO valid_values VALUES(1);
5+
INSERT INTO valid_values VALUES(1024);
6+
7+
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
8+
INSERT INTO invalid_values VALUES('\'aaa\'');
9+
10+
--let $sys_var=ROCKSDB_CONCURRENT_PREPARE
11+
--let $read_only=1
12+
--let $session=0
13+
--source ../include/rocksdb_sys_var.inc
14+
15+
DROP TABLE valid_values;
16+
DROP TABLE invalid_values;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--source include/have_rocksdb.inc
2+
3+
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
4+
INSERT INTO valid_values VALUES(1);
5+
INSERT INTO valid_values VALUES(1024);
6+
7+
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
8+
INSERT INTO invalid_values VALUES('\'aaa\'');
9+
10+
--let $sys_var=ROCKSDB_MANUAL_WAL_FLUSH
11+
--let $read_only=1
12+
--let $session=0
13+
--source ../include/rocksdb_sys_var.inc
14+
15+
DROP TABLE valid_values;
16+
DROP TABLE invalid_values;

0 commit comments

Comments
 (0)