forked from percona/percona-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check upper and lower bound for writebatchwithindex
Upstream commit ID: facebook/mysql-5.6@0bfdb05 PS-8951: Merge percona-202305 (https://jira.percona.com/browse/PS-8951) Summary: rocksdb use Writebatchwithindex(WBWI) to support read your own data. But there are two issues for implementations: 1. facebook/rocksdb#11606: Rocksdb may return deleted row or out of range row during iterating WBWI, see code https://github.com/facebook/rocksdb/blob/main/utilities/write_batch_with_index/write_batch_with_index_internal.cc#L311, when it return due out of range(bound), its DeltaIterator may still valid but point to out of range row. 2. facebook/rocksdb#11607: it doesn't check lower_bound_ even lower_bound_ values is passed to rocksdb with readoptions. see https://github.com/facebook/rocksdb/blob/main/utilities/write_batch_with_index/write_batch_with_index_internal.cc#L306 To workaround these issue, add a variable rocksdb_check_iterate_bounds to control whether we should check iterate bounds and check these bounds inside myrocks if rocksdb_check_iterate_bounds is true. Differential Revision: D46908478 fbshipit-source-id: 765f562928a3ad117d23a177b1b2d9e551b0c0ae
- Loading branch information
Showing
9 changed files
with
250 additions
and
4 deletions.
There are no files selected for viewing
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
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
100 changes: 100 additions & 0 deletions
100
mysql-test/suite/rocksdb_sys_vars/r/rocksdb_check_iterate_bounds_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,100 @@ | ||
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'); | ||
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam; | ||
INSERT INTO invalid_values VALUES('\'aaa\''); | ||
INSERT INTO invalid_values VALUES('\'bbb\''); | ||
SET @start_global_value = @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
SELECT @start_global_value; | ||
@start_global_value | ||
1 | ||
SET @start_session_value = @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
SELECT @start_session_value; | ||
@start_session_value | ||
1 | ||
'# Setting to valid values in global scope#' | ||
"Trying to set variable @@global.ROCKSDB_CHECK_ITERATE_BOUNDS to 1" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = 1; | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Setting the global scope variable back to default" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = DEFAULT; | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Trying to set variable @@global.ROCKSDB_CHECK_ITERATE_BOUNDS to 0" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = 0; | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
0 | ||
"Setting the global scope variable back to default" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = DEFAULT; | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Trying to set variable @@global.ROCKSDB_CHECK_ITERATE_BOUNDS to on" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = on; | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Setting the global scope variable back to default" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = DEFAULT; | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
'# Setting to valid values in session scope#' | ||
"Trying to set variable @@session.ROCKSDB_CHECK_ITERATE_BOUNDS to 1" | ||
SET @@session.ROCKSDB_CHECK_ITERATE_BOUNDS = 1; | ||
SELECT @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@session.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Setting the session scope variable back to default" | ||
SET @@session.ROCKSDB_CHECK_ITERATE_BOUNDS = DEFAULT; | ||
SELECT @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@session.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Trying to set variable @@session.ROCKSDB_CHECK_ITERATE_BOUNDS to 0" | ||
SET @@session.ROCKSDB_CHECK_ITERATE_BOUNDS = 0; | ||
SELECT @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@session.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
0 | ||
"Setting the session scope variable back to default" | ||
SET @@session.ROCKSDB_CHECK_ITERATE_BOUNDS = DEFAULT; | ||
SELECT @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@session.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Trying to set variable @@session.ROCKSDB_CHECK_ITERATE_BOUNDS to on" | ||
SET @@session.ROCKSDB_CHECK_ITERATE_BOUNDS = on; | ||
SELECT @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@session.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Setting the session scope variable back to default" | ||
SET @@session.ROCKSDB_CHECK_ITERATE_BOUNDS = DEFAULT; | ||
SELECT @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@session.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
'# Testing with invalid values in global scope #' | ||
"Trying to set variable @@global.ROCKSDB_CHECK_ITERATE_BOUNDS to 'aaa'" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = 'aaa'; | ||
Got one of the listed errors | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
"Trying to set variable @@global.ROCKSDB_CHECK_ITERATE_BOUNDS to 'bbb'" | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = 'bbb'; | ||
Got one of the listed errors | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
SET @@global.ROCKSDB_CHECK_ITERATE_BOUNDS = @start_global_value; | ||
SELECT @@global.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@global.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
SET @@session.ROCKSDB_CHECK_ITERATE_BOUNDS = @start_session_value; | ||
SELECT @@session.ROCKSDB_CHECK_ITERATE_BOUNDS; | ||
@@session.ROCKSDB_CHECK_ITERATE_BOUNDS | ||
1 | ||
DROP TABLE valid_values; | ||
DROP TABLE invalid_values; |
18 changes: 18 additions & 0 deletions
18
mysql-test/suite/rocksdb_sys_vars/t/rocksdb_check_iterate_bounds_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(1); | ||
INSERT INTO valid_values VALUES(0); | ||
INSERT INTO valid_values VALUES('on'); | ||
|
||
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam; | ||
INSERT INTO invalid_values VALUES('\'aaa\''); | ||
INSERT INTO invalid_values VALUES('\'bbb\''); | ||
|
||
--let $sys_var=ROCKSDB_CHECK_ITERATE_BOUNDS | ||
--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
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