Skip to content

Commit

Permalink
FB8-77: Changed the behavior of purging logs. Now deleting logs first…
Browse files Browse the repository at this point in the history
… and then updating the index (#943)

Summary:
JIRA: https://jira.percona.com/browse/FB8-77

Reference Patch: 832be30
Reference Patch: 0d85250
Reference Patch: e8be5be

Changed the behavior of purging logs. Now deleting logs first and then updating the index.

Previously when purging logs, the index was updated before deleting the logs. This creates problems the disk is full. We should first delete logs to free up disk and then update index.
Pull Request resolved: #943

Reviewed By: lth

Differential Revision: D13930811

Pulled By: lth

fbshipit-source-id: 59c6a6a
  • Loading branch information
abhinav04sharma authored and facebook-github-bot committed Feb 5, 2019
1 parent eb7278c commit 97ae20b
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 132 deletions.
16 changes: 4 additions & 12 deletions mysql-test/suite/binlog/r/binlog_index.result
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ SELECT @index;
binlog.000004
binlog.000005

# crash_purge_critical_after_update_index
# crash_purge_critical_before_update_index
flush logs;
SET SESSION debug="+d,crash_purge_critical_after_update_index";
SET SESSION debug="+d,crash_purge_critical_before_update_index";
purge binary logs TO 'binlog.000006';
ERROR HY000: Lost connection to MySQL server during query
include/rpl_gen_binlog_index_file.inc
Expand Down Expand Up @@ -334,11 +334,9 @@ SET SESSION debug="+d,fault_injection_copy_part_file";
purge binary logs TO 'binlog.000014';
ERROR HY000: Lost connection to MySQL server during query
# Restart the master server
# Test the index file is complete, although is not purged successfully.
# Test if both the index file and binlogs are in sync
show binary logs;
Log_name File_size
binlog.000012 #
binlog.000013 #
binlog.000014 #
binlog.000015 #
binlog.000016 #
Expand All @@ -353,12 +351,10 @@ call mtr.add_suppression("failed to move crash safe index file to index file");
call mtr.add_suppression("failed to update the index file");
PURGE BINARY LOGS TO 'binlog.000014';;
ERROR HY000: I/O error reading log index file
# Test the index file is complete, although is not purged successfully.
# Test if both the index file and binlogs are in sync
# Also this will indicate that binary logging is not disabled.
show binary logs;
Log_name File_size
binlog.000012 #
binlog.000013 #
binlog.000014 #
binlog.000015 #
binlog.000016 #
Expand All @@ -374,8 +370,6 @@ ERROR HY000: You are not using binary logging
# restart
show binary logs;
Log_name File_size
binlog.000012 #
binlog.000013 #
binlog.000014 #
binlog.000015 #
binlog.000016 #
Expand All @@ -395,8 +389,6 @@ ERROR HY000: You are not using binary logging
# restart
show binary logs;
Log_name File_size
binlog.000012 #
binlog.000013 #
binlog.000014 #
binlog.000015 #
binlog.000016 #
Expand Down
12 changes: 8 additions & 4 deletions mysql-test/suite/binlog/t/binlog_index.test
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ file_exists $MYSQLD_DATADIR/binlog.000003;
-- replace_regex /\.[\\\/]binlog/binlog/
SELECT @index;

--echo # crash_purge_critical_after_update_index
--echo # crash_purge_critical_before_update_index
flush logs;

--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="+d,crash_purge_critical_after_update_index";
SET SESSION debug="+d,crash_purge_critical_before_update_index";
--error 2013
purge binary logs TO 'binlog.000006';

Expand Down Expand Up @@ -443,9 +443,11 @@ purge binary logs TO 'binlog.000014';
-- source include/wait_until_connected_again.inc
-- disable_reconnect

-- echo # Test the index file is complete, although is not purged successfully.
-- echo # Test if both the index file and binlogs are in sync
-- source include/show_binary_logs.inc
-- error 1
file_exists $MYSQLD_DATADIR/binlog.000012;
-- error 1
file_exists $MYSQLD_DATADIR/binlog.000013;
file_exists $MYSQLD_DATADIR/binlog.000014;

Expand All @@ -465,10 +467,12 @@ call mtr.add_suppression("failed to update the index file");
-- error ER_IO_ERR_LOG_INDEX_READ
-- eval PURGE BINARY LOGS TO 'binlog.000014';

-- echo # Test the index file is complete, although is not purged successfully.
-- echo # Test if both the index file and binlogs are in sync
-- echo # Also this will indicate that binary logging is not disabled.
-- source include/show_binary_logs.inc
-- error 1
file_exists $MYSQLD_DATADIR/binlog.000012;
-- error 1
file_exists $MYSQLD_DATADIR/binlog.000013;
file_exists $MYSQLD_DATADIR/binlog.000014;

Expand Down
6 changes: 6 additions & 0 deletions share/errmsg-utf8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18718,6 +18718,12 @@ ER_BINLOG_INDEX_PREV_GTID_CORRUPT
ER_BINLOG_CANT_DELETE_TMP_INDEX
eng "%s failed to delete the crash safe index file."

ER_BINLOG_CANT_READ_INDEX
eng "%s failed while reading log index file."

ER_RPL_FAILED_IN_RLI_INIT_INFO
eng "Failed in %s called from Relay_log_info::rli_init_info()."

#
# End of 8.0 FB MySQL error messages.
# (Please read comments from the header of this section before adding error
Expand Down
Loading

0 comments on commit 97ae20b

Please sign in to comment.