Get the App
SLTechnology News&Howtos  ›  Servers  › 

Fix the problem of dropping data in mha 0.58 gtid mode

Shulou Source: shulou.com Published: 2022-06-02 09:59:59 10月03日 Update

Problem description:

In gtid mode, mha fails over. If the Linux host is still alive, it will not compare master logs and obtain differential logs, which may lead to data loss.

Problem fix:

Find the MasterFailover.pm file, which will follow! Remove

If (! $_ server_manager- > is_gtid_auto_pos_enabled ()) {$log- > info (); $log- > info ("* Phase 3.2: Saving Dead Master's Binlog Phase..\ n"); $log- > info (); save_master_binlog ($dead_master);}

The removed code

If ($_ server_manager- > is_gtid_auto_pos_enabled ()) {$log- > info (); $log- > info ("* Phase 3.2: Saving Dead Master's Binlog Phase..\ n"); $log- > info (); save_master_binlog ($dead_master);}

Find the location defined by the apply_binlog_to_master function

Sub apply_binlog_to_master ($) {my $target = shift; my $err_file = "$g_workdir/mysql_from_binlog.err"; my $command = "cat $_ diff_binary_log | mysql-- binary-mode-- user=$target- > {mysql_escaped_user}-- password=$target- > {mysql_escaped_password}-- host=$target- > {ip}-port=$target- > {port}-vvv-unbuffered > $err_file 2 > & 1" $log- > info ("Checking if super_read_only is defined and turned on.."); my ($super_read_only_enabled, $dbh) = MHA::SlaveUtil::check_if_super_read_only ($target- > {hostname}, $target- > {ip}, $target- > {port}, $target- > {user}, $target- > {password}); if ($super_read_only_enabled) {MHA::SlaveUtil::disable_super_read_only ($dbh) } else {$log- > info ("not present or turned off, ignoring.\ n");}

Modified code cat $_ diff_binary_log

Sub apply_binlog_to_master ($) {my $target = shift; my $err_file = "$g_workdir/mysql_from_binlog.err"; my $command = "mysqlbinlog $_ diff_binary_log-- skip-gtids=true | mysql-- binary-mode-- user=$target- > {mysql_escaped_user}-- password=$target- > {mysql_escaped_password}-- host=$target- > {ip}-port=$target- > {port}-vvv-- unbuffered > $err_file 2 > & 1" $log- > info ("Checking if super_read_only is defined and turned on.."); my ($super_read_only_enabled, $dbh) = MHA::SlaveUtil::check_if_super_read_only ($target- > {hostname}, $target- > {ip}, $target- > {port}, $target- > {user}, $target- > {password}); if ($super_read_only_enabled) {MHA::SlaveUtil::disable_super_read_only ($dbh) } else {$log- > info ("not present or turned off, ignoring.\ n");}

Tags: Problem code log data mode following host location function difference failure file risk switch Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology Shulou Tech Info Linux Huawei