~hartmut-php/percona-xtrabackup/bug1089375

« back to all changes in this revision

Viewing changes to innobackupex

  • Committer: Alexey Kopytov
  • Date: 2012-11-15 06:27:29 UTC
  • mfrom: (391.53.7 2.0)
  • Revision ID: akopytov@gmail.com-20121115062729-u7thawpy91fv1d9x
Manual merge from 2.0 (conflicts in xtrabackup.c).

Show diffs side-by-side

added added

removed removed

Lines of Context:
420
420
    # (or finalize the backup by syncing changes if using rsync)
421
421
    backup_files(0);
422
422
 
423
 
    # resume ibbackup and wait till it has finished
424
 
    my $ibbackup_exit_code = resume_ibbackup();
 
423
    # resume ibbackup and wait till log copying is finished
 
424
    resume_ibbackup();
425
425
 
426
426
    # release read locks on all tables
427
427
    mysql_unlockall() if !$option_no_lock;
428
428
 
 
429
    my $ibbackup_exit_code = wait_for_ibbackup_finish();
 
430
 
429
431
    if ( $option_safe_slave_backup && $sql_thread_started) {
430
432
      print STDERR "$prefix: Starting slave SQL thread\n";
431
433
      mysql_send('START SLAVE SQL_THREAD;');
902
904
 
903
905
 
904
906
#
905
 
# resume_ibbackup subroutine signals ibbackup to complete its execution
906
 
# by deleting the 'ibbackup_suspended' file.
 
907
# resume_ibbackup subroutine signals ibbackup to finish log copying by deleting
 
908
# the 'xtrabackup_suspended' file and waits until log copying is stopped,
 
909
# i.e. until 'xtrabackup_suspended' is created again.
 
910
#
 
911
# If this functions detects that the xtrabackup process has terminated, it also
 
912
# sets ibbackup_exit_code and resets ibbackup_pid to avoid trying to reap a
 
913
# non-existing process later
907
914
#
908
915
sub resume_ibbackup {
909
 
    print STDERR "$prefix Resuming ibbackup\n\n";
910
 
    unlink $suspend_file || Die "Failed to delete '$suspend_file': $!";
 
916
    my $pid = -1;
 
917
 
 
918
    $now = current_time();
 
919
    print STDERR "$now  $prefix Waiting for log copying to finish\n\n";
 
920
    unlink $suspend_file || Die "Failed to delete '$suspend_file': $!";
 
921
 
 
922
    for (;;) {
 
923
        # check if the xtrabackup process is still alive _before_ checking if
 
924
        # the file exists to avoid a race condition when the file is created and
 
925
        # the process terminates right after we do the file check
 
926
        $pid = waitpid($ibbackup_pid, &WNOHANG);
 
927
 
 
928
        last if -e $suspend_file;
 
929
 
 
930
        if ($ibbackup_pid == $pid) {
 
931
            # The file doesn't exist, but the process has terminated
 
932
            Die "ibbackup child process has died";
 
933
        }
 
934
 
 
935
        sleep 1;
 
936
    }
 
937
 
 
938
    if ($pid == $ibbackup_pid) {
 
939
        $ibbackup_exit_code = $CHILD_ERROR >> 8;
 
940
        $ibbackup_pid = '';
 
941
    }
 
942
 
 
943
    unlink $suspend_file || Die "Failed to delete '$suspend_file': $!";
 
944
}
 
945
 
 
946
#
 
947
# wait for ibbackup to finish and return its exit code
 
948
#
 
949
sub wait_for_ibbackup_finish {
 
950
    if (!$ibbackup_pid) {
 
951
        # The process has already been reaped.
 
952
        return $ibbackup_exit_code;
 
953
    }
 
954
 
 
955
    $now = current_time();
 
956
    print STDERR "$now  $prefix Waiting for ibbackup (pid=$ibbackup_pid) to finish\n";
911
957
 
912
958
    # wait for ibbackup to finish
913
959
    waitpid($ibbackup_pid, 0);