Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Skip transaction api for replication threads
Summary:
Replication threads are guaranteed to run only the transactions in parallel that are not conflicting. This
enables us to enhance performance by using simple rocksdb write batches. This diff makes the
following changes:

A base class Rdb_transaction is created which handles transaction connection to rocksdb. Moved the current
Rdb_transaction class to Rdb_transaction_impl which uses rocksdb tx api. Created a new class Rdb_writebatch_impl
using rocksdb write batches.

Test Plan:
Enabled rpl_skip_tx_api by default here to make sure we run all the tests in new mode. Will add
a test running replication along with some conflicting delete queries.

Performance testing showed 50% improvemen in replication thread write rate.

Reviewers: yoshinorim, horuff, jkedgar, hermanlee4

Reviewed By: hermanlee4

Subscribers: vasilep, webscalesql-eng

Differential Revision: https://reviews.facebook.net/D60921
  • Loading branch information
santoshbanda committed Sep 26, 2016
1 parent 2f5848e commit cd14963
Show file tree
Hide file tree
Showing 7 changed files with 672 additions and 296 deletions.
4 changes: 4 additions & 0 deletions mysql-test/r/mysqld--help-notwin-profiling.result
Expand Up @@ -1207,6 +1207,9 @@ The following options may be given as the first argument:
--rocksdb-records-in-range=#
Used to override the result of records_in_range(). Set to
a positive number to override
--rocksdb-rpl-skip-tx-api
Use write batches for replication thread instead of tx
api
--rocksdb-seconds-between-stat-computes=#
Sets a number of seconds to wait between optimizer stats
recomputation. Only changed indexes will be refreshed.
Expand Down Expand Up @@ -1913,6 +1916,7 @@ rocksdb-pin-l0-filter-and-index-blocks-in-cache TRUE
rocksdb-rate-limiter-bytes-per-sec 0
rocksdb-read-free-rpl-tables (No default value)
rocksdb-records-in-range 0
rocksdb-rpl-skip-tx-api FALSE
rocksdb-seconds-between-stat-computes 3600
rocksdb-signal-drop-index-thread FALSE
rocksdb-skip-bloom-filter-on-read FALSE
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/r/mysqld--help-notwin.result
Expand Up @@ -1205,6 +1205,9 @@ The following options may be given as the first argument:
--rocksdb-records-in-range=#
Used to override the result of records_in_range(). Set to
a positive number to override
--rocksdb-rpl-skip-tx-api
Use write batches for replication thread instead of tx
api
--rocksdb-seconds-between-stat-computes=#
Sets a number of seconds to wait between optimizer stats
recomputation. Only changed indexes will be refreshed.
Expand Down Expand Up @@ -1910,6 +1913,7 @@ rocksdb-pin-l0-filter-and-index-blocks-in-cache TRUE
rocksdb-rate-limiter-bytes-per-sec 0
rocksdb-read-free-rpl-tables (No default value)
rocksdb-records-in-range 0
rocksdb-rpl-skip-tx-api FALSE
rocksdb-seconds-between-stat-computes 3600
rocksdb-signal-drop-index-thread FALSE
rocksdb-skip-bloom-filter-on-read FALSE
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/rocksdb/r/rocksdb.result
Expand Up @@ -927,6 +927,7 @@ rocksdb_pin_l0_filter_and_index_blocks_in_cache ON
rocksdb_rate_limiter_bytes_per_sec 0
rocksdb_read_free_rpl_tables
rocksdb_records_in_range 50
rocksdb_rpl_skip_tx_api OFF
rocksdb_seconds_between_stat_computes 3600
rocksdb_signal_drop_index_thread OFF
rocksdb_skip_bloom_filter_on_read OFF
Expand Down
@@ -0,0 +1,68 @@
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES(0);
INSERT INTO valid_values VALUES('on');
INSERT INTO valid_values VALUES('off');
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');
SET @start_global_value = @@global.ROCKSDB_RPL_SKIP_TX_API;
SELECT @start_global_value;
@start_global_value
1
'# Setting to valid values in global scope#'
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to 1"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = 1;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to 0"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = 0;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to on"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = on;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to off"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = off;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
0
"Setting the global scope variable back to default"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = DEFAULT;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
"Trying to set variable @@session.ROCKSDB_RPL_SKIP_TX_API to 444. It should fail because it is not session."
SET @@session.ROCKSDB_RPL_SKIP_TX_API = 444;
ERROR HY000: Variable 'rocksdb_rpl_skip_tx_api' is a GLOBAL variable and should be set with SET GLOBAL
'# Testing with invalid values in global scope #'
"Trying to set variable @@global.ROCKSDB_RPL_SKIP_TX_API to 'aaa'"
SET @@global.ROCKSDB_RPL_SKIP_TX_API = 'aaa';
Got one of the listed errors
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
SET @@global.ROCKSDB_RPL_SKIP_TX_API = @start_global_value;
SELECT @@global.ROCKSDB_RPL_SKIP_TX_API;
@@global.ROCKSDB_RPL_SKIP_TX_API
1
DROP TABLE valid_values;
DROP TABLE invalid_values;
@@ -0,0 +1,18 @@
--source include/have_rocksdb.inc

CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO valid_values VALUES(1);
INSERT INTO valid_values VALUES(0);
INSERT INTO valid_values VALUES('on');
INSERT INTO valid_values VALUES('off');

CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
INSERT INTO invalid_values VALUES('\'aaa\'');

--let $sys_var=ROCKSDB_RPL_SKIP_TX_API
--let $read_only=0
--let $session=0
--source suite/sys_vars/inc/rocksdb_sys_var.inc

DROP TABLE valid_values;
DROP TABLE invalid_values;

0 comments on commit cd14963

Please sign in to comment.