-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recover raft logs by removing partial trxs
Summary: 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 MYSQL_BIN_LOG::recover() Reviewed By: anirbanr-fb Differential Revision: D24628821 fbshipit-source-id: 5694a593d91
- Loading branch information
1 parent
6b1db2c
commit 6ab1c7c
Showing
13 changed files
with
337 additions
and
7 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
47 changes: 47 additions & 0 deletions
47
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,47 @@ | ||
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(".*"); | ||
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: 1362" | ||
"Restarting server_2" | ||
include/rpl_restart_server.inc [server_number=2] | ||
start slave sql_thread; | ||
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 |
63 changes: 63 additions & 0 deletions
63
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,63 @@ | ||
source ../include/raft_3_node.inc; | ||
|
||
call mtr.add_suppression(".*"); | ||
|
||
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; | ||
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
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.