Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds capability to set different BottommostLevelCompaction option for…
… MyRocks Manual Compaction Upstream commit ID : fb-mysql-5.6.35/49e8df3e1ce20d06b41f14ad9d471be9e0235a55 PS-7767 : Merge percona-202103 Summary: Currently BottommostLevelCompaction is set to default kForceOptimized for manual compaction. This is fine usually. However, for privacy triggered compactions, it does not make much sense, because it compacts Lmax SST files that do not have any overlapping key updates at all. This adds a session variable to specify the option for bottommost level compaction before triggering manual compaction. Reviewed By: yoshinorim, yizhang82 Differential Revision: D27665464 fbshipit-source-id: 2bbdf04ec18
- Loading branch information
Showing
8 changed files
with
266 additions
and
13 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
mysql-test/suite/rocksdb/r/manual_compaction_bottommost_level.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
CREATE PROCEDURE compact_start() | ||
BEGIN | ||
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_compact_write_bytes'; | ||
END// | ||
CREATE PROCEDURE compact_end() | ||
BEGIN | ||
select case when variable_value-@c > 0 then 'true' else 'false' end as checked from performance_schema.global_status where variable_name='rocksdb_compact_write_bytes'; | ||
END// | ||
CREATE TABLE t1 ( | ||
a int not null, | ||
b int not null, | ||
primary key (a,b), | ||
key (b) | ||
) ENGINE=RocksDB; | ||
DELETE FROM t1; | ||
set @@session.rocksdb_manual_compaction_bottommost_level='kSkip'; | ||
call compact_start(); | ||
set @@global.rocksdb_compact_cf = 'default'; | ||
call compact_end(); | ||
checked | ||
true | ||
set @@session.rocksdb_manual_compaction_bottommost_level='kSkip'; | ||
call compact_start(); | ||
set @@global.rocksdb_compact_cf = 'default'; | ||
call compact_end(); | ||
checked | ||
false | ||
set @@session.rocksdb_manual_compaction_bottommost_level='kForceOptimized'; | ||
call compact_start(); | ||
set @@global.rocksdb_compact_cf = 'default'; | ||
call compact_end(); | ||
checked | ||
true | ||
DROP PROCEDURE compact_start; | ||
DROP PROCEDURE compact_end; | ||
drop table t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
mysql-test/suite/rocksdb/t/manual_compaction_bottommost_level-master.opt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--loose-rocksdb_max_subcompactions=1 | ||
--loose-rocksdb_default_cf_options=target_file_size_base=100k;max_bytes_for_level_multiplier=1;max_bytes_for_level_base=1m;target_file_size_multiplier=1 |
48 changes: 48 additions & 0 deletions
48
mysql-test/suite/rocksdb/t/manual_compaction_bottommost_level.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--source include/have_rocksdb.inc | ||
|
||
DELIMITER //; | ||
CREATE PROCEDURE compact_start() | ||
BEGIN | ||
select variable_value into @c from performance_schema.global_status where variable_name='rocksdb_compact_write_bytes'; | ||
END// | ||
CREATE PROCEDURE compact_end() | ||
BEGIN | ||
select case when variable_value-@c > 0 then 'true' else 'false' end as checked from performance_schema.global_status where variable_name='rocksdb_compact_write_bytes'; | ||
END// | ||
DELIMITER ;// | ||
|
||
CREATE TABLE t1 ( | ||
a int not null, | ||
b int not null, | ||
primary key (a,b), | ||
key (b) | ||
) ENGINE=RocksDB; | ||
|
||
# Populate tables | ||
let $max = 1000; | ||
let $table = t1; | ||
--source ../include/drop_table_repopulate_table.inc | ||
|
||
# compact to move all data in files in Lmax level | ||
set @@session.rocksdb_manual_compaction_bottommost_level='kSkip'; | ||
call compact_start(); | ||
set @@global.rocksdb_compact_cf = 'default'; | ||
call compact_end(); # should return true as compaction of lower levels is performed | ||
|
||
# skip compaction of files in bottommost level i.e. Lmax->Lmax compaction and ensure rocksdb_compact_write_byte | ||
# does not increase after compaction | ||
set @@session.rocksdb_manual_compaction_bottommost_level='kSkip'; | ||
call compact_start(); | ||
set @@global.rocksdb_compact_cf = 'default'; | ||
call compact_end(); # should return false as files only in bottommost layer | ||
|
||
# restore 'kForceOptimized' default setting and check that value of rocksdb_compact_write_byte increses after compaction | ||
set @@session.rocksdb_manual_compaction_bottommost_level='kForceOptimized'; | ||
call compact_start(); | ||
set @@global.rocksdb_compact_cf = 'default'; | ||
call compact_end(); # should return true | ||
|
||
# cleanup | ||
DROP PROCEDURE compact_start; | ||
DROP PROCEDURE compact_end; | ||
drop table t1; |
114 changes: 114 additions & 0 deletions
114
mysql-test/suite/rocksdb_sys_vars/r/rocksdb_manual_compaction_bottommost_level_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam; | ||
INSERT INTO valid_values VALUES('kSkip'); | ||
INSERT INTO valid_values VALUES('kIfHaveCompactionFilter'); | ||
INSERT INTO valid_values VALUES('kForce'); | ||
INSERT INTO valid_values VALUES('kForceOptimized'); | ||
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam; | ||
INSERT INTO invalid_values VALUES('\'aaa\''); | ||
SET @start_global_value = @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
SELECT @start_global_value; | ||
@start_global_value | ||
kForceOptimized | ||
SET @start_session_value = @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
SELECT @start_session_value; | ||
@start_session_value | ||
kForceOptimized | ||
'# Setting to valid values in global scope#' | ||
"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kSkip" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kSkip; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kSkip | ||
"Setting the global scope variable back to default" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kIfHaveCompactionFilter" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kIfHaveCompactionFilter; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kIfHaveCompactionFilter | ||
"Setting the global scope variable back to default" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kForce" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kForce; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForce | ||
"Setting the global scope variable back to default" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kForceOptimized" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kForceOptimized; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Setting the global scope variable back to default" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
'# Setting to valid values in session scope#' | ||
"Trying to set variable @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kSkip" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kSkip; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kSkip | ||
"Setting the session scope variable back to default" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Trying to set variable @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kIfHaveCompactionFilter" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kIfHaveCompactionFilter; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kIfHaveCompactionFilter | ||
"Setting the session scope variable back to default" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Trying to set variable @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kForce" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kForce; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForce | ||
"Setting the session scope variable back to default" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Trying to set variable @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to kForceOptimized" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = kForceOptimized; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
"Setting the session scope variable back to default" | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = DEFAULT; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
'# Testing with invalid values in global scope #' | ||
"Trying to set variable @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL to 'aaa'" | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = 'aaa'; | ||
Got one of the listed errors | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
SET @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = @start_global_value; | ||
SELECT @@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@global.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
SET @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL = @start_session_value; | ||
SELECT @@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL; | ||
@@session.ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
kForceOptimized | ||
DROP TABLE valid_values; | ||
DROP TABLE invalid_values; |
18 changes: 18 additions & 0 deletions
18
mysql-test/suite/rocksdb_sys_vars/t/rocksdb_manual_compaction_bottommost_level_basic.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--source include/have_rocksdb.inc | ||
|
||
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam; | ||
INSERT INTO valid_values VALUES('kSkip'); | ||
INSERT INTO valid_values VALUES('kIfHaveCompactionFilter'); | ||
INSERT INTO valid_values VALUES('kForce'); | ||
INSERT INTO valid_values VALUES('kForceOptimized'); | ||
|
||
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam; | ||
INSERT INTO invalid_values VALUES('\'aaa\''); | ||
|
||
--let $sys_var=ROCKSDB_MANUAL_COMPACTION_BOTTOMMOST_LEVEL | ||
--let $read_only=0 | ||
--let $session=1 | ||
--source ../include/rocksdb_sys_var.inc | ||
|
||
DROP TABLE valid_values; | ||
DROP TABLE invalid_values; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters