PDA

View Full Version : Mysql-zrm 2 & 3 bug that ignores the mysqldump exitcodes. Backup integrity?



themadcanudist
October 10th, 2014, 12:42 PM
Hey guys,

I believe I stumbled upon a fairly major bug when using mysql-zrm 2 and 3 (EPEL version) where the exitcodes of the command pipeline when using logical backups are ignored. It seems like the logic for it is half implemented or I'm missing something obvious. I stumbled upon this issue when noticing that one database installation wasn't actually backing up all the data, but mysql-zrm was reporting it as a success. When debugging I found that the mysqldump was failing with an exitcode of 2 and this message:

"VIEW references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)"

The temporary file that records the $PIPESTATUS[@] of the run shows 2 as well, but the $rt that's tested is 0. Here is the patch I created that resolves the issue.

--- /usr/bin/mysql-zrm-backup 2014-07-25 13:16:37.000000000 -0400
+++ mysql-zrm-backup 2014-10-10 15:32:05.558346707 -0400
@@ -1833,7 +1833,29 @@
if( $abort_flag ){
&abortAndDie( );
}
- if( $r > 0 ) {
+
+ # Check the pipestatus as it will indicate if something horrendously wrong
+ # occurred with mysqldump
+ unless (open(PIPESTATUS, $pipestatus)) {
+ &printAndDie( "Could not read pipestatus file for pipe exitcode ".$pipestatus."\n" );
+ }
+ my @pipe_exitcodes = <PIPESTATUS>;
+ close(PIPESTATUS);
+ if( ! @pipe_exitcodes ) {
+ &printAndDie( "Could not get pipe exitcodes!" );
+ }
+
+ # Check exitcode of every command in pipeline
+ my $pipe_exit = 0;
+ my @s_exitcodes = split(/\s+/, $pipe_exitcodes[0]);
+ foreach (@s_exitcodes) {
+ if ($_ > 0) {
+ $pipe_exit = $_;
+ last;
+ }
+ }
+
+ if( $r > 0 or $pipe_exit > 0) {
&printLog("Command exit status is : $r \n" );
&printCommandOutputToLog( "ERROR", "command is : $command", $CMDERR );
&printCommandOutputToLog( "ERROR", "pipe exit status", $pipestatus );
@@ -1841,8 +1863,8 @@
}elsif ( -s $CMDERR ) {
&printCommandOutputToLog( ($CMDERR =~ /warning/i) ? "INFO" : "WARNING", "mysqldump output for command : $command", $CMDERR );
}
unlink($CMDERR);
unlink($pipestatus);
}

sub checkAndBackupReplicationData()




Can anyone comment on this?

ajoyna1
April 1st, 2015, 11:41 PM
I'm missing something obvious. I stumbled upon this issue when noticing that one database installation wasn't actually backing up all the data, but mysql-zrm was reporting it as a success. When debugging I found that the mysqldump was failing with an exitcode





Cut down your exam stress by using our latest http://www.e-six-sigma.com/ (http://www.e-six-sigma.com) and high quality gmat and We provide updated hodges.edu (http://www.hodges.edu/) with 100% pass guarantee along with Caldwell College (http://en.wikipedia.org/wiki/Caldwell_University)