forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[raft] recover raft logs by removing partial trxs
Summary: Port D24628821 mysqld removes partial trxs in the tail of trx log (named binary-logs on primaries and apply-logs on secondaries) during startup. However, relay logs were not of much importance since it was anyways discarded and a new one would be created. However, with raft, this is not ideal. Relay logs are raft logs on secondaries and have to be kept around (and kept sane and consistent). This diff adds the ability to remove partial trxs from raft/relay logs. Much of the code to open the last relay log (based on relay log index) and identify partial trxs is borrowed from existing logic in MYSQL_BIN_LOG::open_binlog() and binlog_recover() Reviewed By: Pushapgl Differential Revision: D26447448 --------------------------------------------------------------------------------- Fix load_mi_and_rli_from_repositories for raft Summary: The load_mi_and_rli_from_repositories() function was updated in 8.0.28, but the raft call was still using the old definition and triggered a deadlock. Fix the call. Reviewed By: yichenshen Differential Revision: D38872610 --------------------------------------------------------------------------------- always release data_lock mutex to avoid deadlock Summary: in stage-1 replicaset, when kill a secondary instance, sometime the instance will run into deadlock due to process_raft_queue thread forgot to release its acquired mutex in raft_change_master Reviewed By: Pushapgl, bhatvinay Differential Revision: D27602667
- Loading branch information
Showing
12 changed files
with
387 additions
and
2 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
51 changes: 51 additions & 0 deletions
51
mysql-test/suite/rpl_raft/r/rpl_raft_recover_raft_log.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,51 @@ | ||
include/raft_3_node.inc | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. | ||
[connection master] | ||
call mtr.add_suppression(".*"); | ||
include/rpl_connect.inc [creating server_4] | ||
include/rpl_connect.inc [creating server_5] | ||
create table t1 (a int primary key) engine = innodb; | ||
insert into t1 values(1); | ||
insert into t1 values(2); | ||
include/sync_slave_sql_with_master.inc | ||
include/sync_slave_sql_with_master.inc | ||
select * from t1; | ||
a | ||
1 | ||
2 | ||
select * from t1; | ||
a | ||
1 | ||
2 | ||
select sleep(10); | ||
sleep(10) | ||
0 | ||
"raft file: binary-logs-13001.000002" | ||
"raft file pos: 1471" | ||
"Restarting server_2" | ||
include/rpl_restart_server.inc [server_number=2] | ||
start slave sql_thread; | ||
Warnings: | ||
Note 3083 Replication thread(s) for channel '' are already runnning. | ||
insert into t1 values(3); | ||
include/sync_slave_sql_with_master.inc | ||
include/sync_slave_sql_with_master.inc | ||
select * from t1; | ||
a | ||
1 | ||
2 | ||
3 | ||
select * from t1; | ||
a | ||
1 | ||
2 | ||
3 | ||
drop table t1; | ||
include/sync_slave_sql_with_master.inc | ||
include/sync_slave_sql_with_master.inc | ||
include/rpl_end.inc |
1 change: 1 addition & 0 deletions
1
mysql-test/suite/rpl_raft/t/rpl_raft_recover_raft_log-slave.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 @@ | ||
--initialize --innodb_page_size=16k |
82 changes: 82 additions & 0 deletions
82
mysql-test/suite/rpl_raft/t/rpl_raft_recover_raft_log.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,82 @@ | ||
source ../include/raft_3_node.inc; | ||
|
||
call mtr.add_suppression(".*"); | ||
|
||
# Create connections to server 4 and 5 (these are not in the ring) | ||
let $rpl_server_number= 4; | ||
let $rpl_connection_name= server_4; | ||
source include/rpl_connect.inc; | ||
--disable_query_log | ||
connection server_4; | ||
call mtr.add_suppression(".*using --replicate-same-server-id in conjunction with --log-slave-updates.*"); | ||
--enable_query_log | ||
|
||
let $rpl_server_number= 5; | ||
let $rpl_connection_name= server_5; | ||
source include/rpl_connect.inc; | ||
--disable_query_log | ||
connection server_5; | ||
call mtr.add_suppression(".*using --replicate-same-server-id in conjunction with --log-slave-updates.*"); | ||
--enable_query_log | ||
|
||
connection server_1; | ||
create table t1 (a int primary key) engine = innodb; | ||
insert into t1 values(1); | ||
insert into t1 values(2); | ||
|
||
let $sync_slave_connection= server_2; | ||
source include/sync_slave_sql_with_master.inc; | ||
let $sync_slave_connection= server_3; | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
connection server_2; | ||
select * from t1; | ||
|
||
connection server_3; | ||
select * from t1; | ||
|
||
connection server_2; | ||
select sleep(10); | ||
|
||
# Expand this test later to cover multiple scenarios | ||
let $server2_datadir = `select @@datadir`; | ||
let $server2_raft_file = query_get_value("SHOW SLAVE STATUS", "Relay_Log_File", 1); | ||
let $server2_raft_file_pos = query_get_value("SHOW SLAVE STATUS", "Relay_Log_Pos", 1); | ||
echo "raft file: $server2_raft_file"; | ||
echo "raft file pos: $server2_raft_file_pos"; | ||
let $half = `select ROUND($server2_raft_file_pos / 2)`; | ||
exec truncate -s $half $server2_datadir/$server2_raft_file; | ||
|
||
echo "Restarting server_2"; | ||
let $rpl_server_number = 2; | ||
source include/rpl_restart_server.inc; | ||
|
||
connection server_2; | ||
# wait for raft plugin initialzed | ||
sleep 10; | ||
start slave sql_thread; | ||
|
||
connection server_1; | ||
insert into t1 values(3); | ||
|
||
let $sync_slave_connection= server_2; | ||
source include/sync_slave_sql_with_master.inc; | ||
let $sync_slave_connection= server_3; | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
connection server_2; | ||
select * from t1; | ||
|
||
connection server_3; | ||
select * from t1; | ||
|
||
# cleanup | ||
connection server_1; | ||
drop table t1; | ||
|
||
let $sync_slave_connection= server_2; | ||
source include/sync_slave_sql_with_master.inc; | ||
let $sync_slave_connection= server_3; | ||
source include/sync_slave_sql_with_master.inc; | ||
|
||
source include/rpl_end.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
SET @start_recover_raft_log = @@global.recover_raft_log; | ||
SELECT @start_recover_raft_log; | ||
@start_recover_raft_log | ||
1 | ||
SET @@global.recover_raft_log = DEFAULT; | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
1 | ||
SET @@global.recover_raft_log = false; | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
0 | ||
SET @@global.recover_raft_log = true; | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
1 | ||
SET @@global.recover_raft_log = 1; | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
1 | ||
SET @@global.recover_raft_log = 0; | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
0 | ||
SET @@global.recover_raft_log = -1; | ||
ERROR 42000: Variable 'recover_raft_log' can't be set to the value of '-1' | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
0 | ||
SET @@global.recover_raft_log = 100; | ||
ERROR 42000: Variable 'recover_raft_log' can't be set to the value of '100' | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
0 | ||
SET @@session.recover_raft_log = 10; | ||
ERROR HY000: Variable 'recover_raft_log' is a GLOBAL variable and should be set with SET GLOBAL | ||
SELECT @@session.recover_raft_log; | ||
ERROR HY000: Variable 'recover_raft_log' is a GLOBAL variable | ||
SET @@global.recover_raft_log = @start_recover_raft_log; | ||
SELECT @@global.recover_raft_log; | ||
@@global.recover_raft_log | ||
1 |
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,32 @@ | ||
SET @start_recover_raft_log = @@global.recover_raft_log; | ||
SELECT @start_recover_raft_log; | ||
|
||
SET @@global.recover_raft_log = DEFAULT; | ||
SELECT @@global.recover_raft_log; | ||
|
||
SET @@global.recover_raft_log = false; | ||
SELECT @@global.recover_raft_log; | ||
|
||
SET @@global.recover_raft_log = true; | ||
SELECT @@global.recover_raft_log; | ||
|
||
SET @@global.recover_raft_log = 1; | ||
SELECT @@global.recover_raft_log; | ||
|
||
SET @@global.recover_raft_log = 0; | ||
SELECT @@global.recover_raft_log; | ||
|
||
--Error ER_WRONG_VALUE_FOR_VAR | ||
SET @@global.recover_raft_log = -1; | ||
SELECT @@global.recover_raft_log; | ||
--Error ER_WRONG_VALUE_FOR_VAR | ||
SET @@global.recover_raft_log = 100; | ||
SELECT @@global.recover_raft_log; | ||
|
||
--ERROR ER_GLOBAL_VARIABLE | ||
SET @@session.recover_raft_log = 10; | ||
--ERROR ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
SELECT @@session.recover_raft_log; | ||
|
||
SET @@global.recover_raft_log = @start_recover_raft_log; | ||
SELECT @@global.recover_raft_log; |
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
Oops, something went wrong.