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.
Add an option to abort/ignore server when hitting data corruption
Upstream commit ID: facebook/mysql-5.6@6ea4040 PS-8494: Merge percona-202206 (https://jira.percona.com/browse/PS-8494) Summary: When hitting the HA_ERR_ROCKSDB_CORRUPT_DATA error in myrocks, the current behavior is to fail the query. We want to change the behavior to provide a choice between: 1. Fail the query with error HA_ERR_ROCKSDB_CORRUPT_DATA 2. Crash the server 3. Pass the query with warning We introduce one enum corrupt_data_action in myrocks to control the behavior. The reason for the behavior change is: - [ABORT_SERVER] When the corrupted data is introduced in myrocks layer due to some reason (e.g random hardware error), we want to crash the server to prevent the corrupted data being copied to other instances in the replicaset. - [WARNING] We also want to provide the ability for quick mitigation. We can quickly delete the corrupted data if we pass the query with warning. This is only used for issue mitigation reason. The diff is to fix the issue of S301551. Reviewed By: yoshinorim Differential Revision: D40390954 fbshipit-source-id: f46ff698e552c0cac2ca8fd65aaa80d654d47480
- Loading branch information
1 parent
cfeabee
commit 455a65d
Showing
7 changed files
with
220 additions
and
9 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
mysql-test/suite/rocksdb/r/error_abort_warning_on_corrupt_data.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,50 @@ | ||
SET SESSION debug="+d, stimulate_corrupt_data_read"; | ||
CREATE DATABASE a; | ||
USE a; | ||
CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdB; | ||
INSERT INTO t1 VALUES (3, 'bar'); | ||
INSERT INTO t1 VALUES (4, 'bar'); | ||
read | ||
fail query | ||
SET GLOBAL rocksdb_corrupt_data_action = ERROR; | ||
select * from t1; | ||
ERROR HY000: Got error 505 'Found data corruption.' from ROCKSDB | ||
fail server | ||
SET GLOBAL rocksdb_corrupt_data_action = ABORT_SERVER; | ||
select * from t1; | ||
SET SESSION debug="+d, stimulate_corrupt_data_read"; | ||
pass query with warning | ||
SET GLOBAL rocksdb_corrupt_data_action = WARNING; | ||
select * from t1; | ||
a b | ||
3 bar | ||
4 bar | ||
SET SESSION debug="-d, stimulate_corrupt_data_read"; | ||
write | ||
USE a; | ||
CREATE table t2 ( | ||
pk0 int primary key auto_increment, | ||
sk int, | ||
val int default 0, | ||
unique(sk) | ||
) engine=rocksdb; | ||
insert into t2 (sk) values (1), (2); | ||
SET SESSION debug="+d, stimulate_corrupt_data_update"; | ||
fail query | ||
SET GLOBAL rocksdb_corrupt_data_action = ERROR; | ||
insert into t2 (sk) values (1), (2) on duplicate key update val = val + 1; | ||
ERROR HY000: Got error 505 'Found data corruption.' from ROCKSDB | ||
fail server | ||
SET GLOBAL rocksdb_corrupt_data_action = ABORT_SERVER; | ||
insert into t2 (sk) values (1), (2) on duplicate key update val = val + 1; | ||
SET SESSION debug="+d, stimulate_corrupt_data_update"; | ||
pass query with warning | ||
SET GLOBAL rocksdb_corrupt_data_action = WARNING; | ||
insert into t2 (sk) values (1), (2) on duplicate key update val = val + 1; | ||
SET SESSION debug="-d, stimulate_corrupt_data_update"; | ||
select * from t2; | ||
pk0 sk val | ||
1 1 1 | ||
2 2 1 | ||
DROP database a; | ||
SET GLOBAL rocksdb_corrupt_data_action = default; |
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
1 change: 1 addition & 0 deletions
1
mysql-test/suite/rocksdb/t/error_abort_warning_on_corrupt_data-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 @@ | ||
--nowarnings |
87 changes: 87 additions & 0 deletions
87
mysql-test/suite/rocksdb/t/error_abort_warning_on_corrupt_data.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,87 @@ | ||
--source include/have_debug.inc | ||
--source include/not_parallel.inc | ||
--source include/have_rocksdb.inc | ||
--source suite/rocksdb/include/have_write_committed.inc | ||
|
||
let DATADIR_LOCATION=$MYSQLTEST_VARDIR/mysqld.1/data; | ||
|
||
SET SESSION debug="+d, stimulate_corrupt_data_read"; | ||
|
||
CREATE DATABASE a; | ||
USE a; | ||
CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdB; | ||
|
||
INSERT INTO t1 VALUES (3, 'bar'); | ||
INSERT INTO t1 VALUES (4, 'bar'); | ||
|
||
--echo read | ||
|
||
--echo fail query | ||
SET GLOBAL rocksdb_corrupt_data_action = ERROR; | ||
--error 1296 | ||
select * from t1; | ||
|
||
--echo fail server | ||
SET GLOBAL rocksdb_corrupt_data_action = ABORT_SERVER; | ||
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR,1296 | ||
select * from t1; | ||
|
||
--remove_file $DATADIR_LOCATION/.rocksdb/ROCKSDB_CORRUPTED | ||
|
||
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect | ||
--enable_reconnect | ||
let $WAIT_COUNT=6000; | ||
--source include/wait_time_until_connected_again.inc | ||
|
||
SET SESSION debug="+d, stimulate_corrupt_data_read"; | ||
|
||
--echo pass query with warning | ||
SET GLOBAL rocksdb_corrupt_data_action = WARNING; | ||
select * from t1; | ||
|
||
SET SESSION debug="-d, stimulate_corrupt_data_read"; | ||
|
||
--echo write | ||
|
||
USE a; | ||
CREATE table t2 ( | ||
pk0 int primary key auto_increment, | ||
sk int, | ||
val int default 0, | ||
unique(sk) | ||
) engine=rocksdb; | ||
|
||
insert into t2 (sk) values (1), (2); | ||
|
||
SET SESSION debug="+d, stimulate_corrupt_data_update"; | ||
|
||
--echo fail query | ||
SET GLOBAL rocksdb_corrupt_data_action = ERROR; | ||
--error 1296 | ||
insert into t2 (sk) values (1), (2) on duplicate key update val = val + 1; | ||
|
||
--echo fail server | ||
SET GLOBAL rocksdb_corrupt_data_action = ABORT_SERVER; | ||
--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR,1296 | ||
insert into t2 (sk) values (1), (2) on duplicate key update val = val + 1; | ||
|
||
--remove_file $DATADIR_LOCATION/.rocksdb/ROCKSDB_CORRUPTED | ||
|
||
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect | ||
--enable_reconnect | ||
let $WAIT_COUNT=6000; | ||
--source include/wait_time_until_connected_again.inc | ||
|
||
SET SESSION debug="+d, stimulate_corrupt_data_update"; | ||
|
||
--echo pass query with warning | ||
SET GLOBAL rocksdb_corrupt_data_action = WARNING; | ||
insert into t2 (sk) values (1), (2) on duplicate key update val = val + 1; | ||
|
||
SET SESSION debug="-d, stimulate_corrupt_data_update"; | ||
|
||
select * from t2; | ||
|
||
DROP database a; | ||
|
||
SET GLOBAL rocksdb_corrupt_data_action = default; |
10 changes: 10 additions & 0 deletions
10
mysql-test/suite/rocksdb_sys_vars/r/rocksdb_corrupt_data_action_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,10 @@ | ||
SET GLOBAL rocksdb_corrupt_data_action = ERROR; | ||
SET GLOBAL rocksdb_corrupt_data_action = ABORT_SERVER; | ||
SET GLOBAL rocksdb_corrupt_data_action = WARNING; | ||
== wrong argument type | ||
SET GLOBAL rocksdb_corrupt_data_action = "abc"; | ||
ERROR 42000: Variable 'rocksdb_corrupt_data_action' can't be set to the value of 'abc' | ||
== wrong argument type | ||
SET GLOBAL rocksdb_corrupt_data_action = 4; | ||
ERROR 42000: Variable 'rocksdb_corrupt_data_action' can't be set to the value of '4' | ||
SET GLOBAL rocksdb_corrupt_data_action = default; |
15 changes: 15 additions & 0 deletions
15
mysql-test/suite/rocksdb_sys_vars/t/rocksdb_corrupt_data_action_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,15 @@ | ||
--source include/have_rocksdb.inc | ||
|
||
SET GLOBAL rocksdb_corrupt_data_action = ERROR; | ||
SET GLOBAL rocksdb_corrupt_data_action = ABORT_SERVER; | ||
SET GLOBAL rocksdb_corrupt_data_action = WARNING; | ||
|
||
--echo == wrong argument type | ||
--error 1231 | ||
SET GLOBAL rocksdb_corrupt_data_action = "abc"; | ||
|
||
--echo == wrong argument type | ||
--error 1231 | ||
SET GLOBAL rocksdb_corrupt_data_action = 4; | ||
|
||
SET GLOBAL rocksdb_corrupt_data_action = default; |
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