forked from percona/percona-server
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement RocksDB file-level checksums (percona#1280)
Upstream commit ID: facebook/mysql-5.6@14df9f1 PS-8951: Merge percona-202305 (https://jira.percona.com/browse/PS-8951) Summary: Add a new boolean system variable rocksdb_file_checksums. Pull Request resolved: facebook/mysql-5.6#1280 Reviewed By: hermanlee Differential Revision: D43964275 Pulled By: sunshine-Chun fbshipit-source-id: fece9aedde36e793f3843df48c1ee1da5c995024
- Loading branch information
1 parent
29ae1c2
commit 091a250
Showing
8 changed files
with
111 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TABLE t1 ( | ||
a INT NOT NULL, b CHAR(128), | ||
PRIMARY KEY (a) COMMENT 'cfname=cf1') ENGINE=ROCKSDB; | ||
INSERT INTO t1 VALUES (1, "foo"); | ||
INSERT INTO t1 VALUES (2, "bar"); | ||
# restart | ||
include/assert.inc [RocksDB file checksums must be enabled] | ||
SELECT * FROM t1; | ||
a b | ||
1 foo | ||
2 bar | ||
SET GLOBAL rocksdb_pause_background_work = 1; | ||
# Kill the server | ||
# restart | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--loose-rocksdb-file-checksums |
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,53 @@ | ||
--source include/have_rocksdb.inc | ||
|
||
--let $sst_dir=`SELECT CONCAT(@@datadir, @@rocksdb_datadir)` | ||
|
||
CREATE TABLE t1 ( | ||
a INT NOT NULL, b CHAR(128), | ||
PRIMARY KEY (a) COMMENT 'cfname=cf1') ENGINE=ROCKSDB; | ||
INSERT INTO t1 VALUES (1, "foo"); | ||
INSERT INTO t1 VALUES (2, "bar"); | ||
|
||
# Restart to check the file checksums | ||
--source include/restart_mysqld.inc | ||
|
||
--let $assert_text = RocksDB file checksums must be enabled | ||
--let $assert_cond = @@rocksdb_file_checksums = 1 | ||
--source include/assert.inc | ||
|
||
SELECT * FROM t1; | ||
|
||
SET GLOBAL rocksdb_pause_background_work = 1; | ||
|
||
let sst_file=`SELECT SST_NAME | ||
FROM INFORMATION_SCHEMA.rocksdb_index_file_map AS file_map | ||
INNER JOIN INFORMATION_SCHEMA.rocksdb_ddl AS ddl | ||
ON file_map.COLUMN_FAMILY = ddl.COLUMN_FAMILY`; | ||
|
||
--let sst=$sst_dir/$sst_file | ||
--file_exists $sst | ||
|
||
--copy_file $sst $sst.bak | ||
|
||
--exec echo "corrupt me" | dd if=$sst of=$sst conv=notrunc seek=100 bs=1 count=10 | ||
|
||
--let $fail_err_log=$MYSQLTEST_VARDIR/checksum-fail.err | ||
|
||
# Cannot shutdown with background threads stopped, thus kill it | ||
--source include/kill_mysqld.inc | ||
|
||
# Must fail to start. This used to grep $fail_err_log for the specific file | ||
# checksum corruption error, but intermittently it hit block checksum error on | ||
# DB open first. | ||
--error 1 | ||
exec $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf | ||
--rocksdb-file-checksums > $fail_err_log 2>&1; | ||
|
||
--remove_file $sst | ||
--move_file $sst.bak $sst | ||
|
||
--source include/start_mysqld.inc | ||
|
||
--remove_file $fail_err_log | ||
|
||
DROP TABLE t1; |
7 changes: 7 additions & 0 deletions
7
mysql-test/suite/rocksdb_sys_vars/r/rocksdb_file_checksums_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,7 @@ | ||
SET @start_global_value = @@global.ROCKSDB_FILE_CHECKSUMS; | ||
SELECT @start_global_value; | ||
@start_global_value | ||
0 | ||
"Trying to set variable @@global.ROCKSDB_FILE_CHECKSUMS to 444. It should fail because it is readonly." | ||
SET @@global.ROCKSDB_FILE_CHECKSUMS = 444; | ||
ERROR HY000: Variable 'rocksdb_file_checksums' is a read only variable |
6 changes: 6 additions & 0 deletions
6
mysql-test/suite/rocksdb_sys_vars/t/rocksdb_file_checksums_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,6 @@ | ||
--source include/have_rocksdb.inc | ||
|
||
--let $sys_var=ROCKSDB_FILE_CHECKSUMS | ||
--let $read_only=1 | ||
--let $session=0 | ||
--source ../include/rocksdb_sys_var.inc |
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