Changeset 157

Show
Ignore:
Timestamp:
06/02/10 20:15:15 (4 years ago)
Author:
depesz
Message:

1. Fix missing arg for sprintf in handling of errors in syswrite
2. add call to pg_stop_backup() in cleanup procedure
3. add handling of SIGPIPE which can happen if user provided bad local directory.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/omnipitr/lib/OmniPITR/Program/Backup/Master.pm

    r154 r157  
    202202    my %ARGS = @_; 
    203203 
     204    $SIG{ 'PIPE' } = sub { $self->clean_and_die( 'Got SIGPIPE while tarring %s for %s', $ARGS{ 'tar_dir' }, $self->{ 'sigpipeinfo' } ); }; 
     205 
    204206    my @compression_command = ( $self->{ 'nice-path' }, $self->{ 'tar-path' }, 'cf', '-' ); 
    205207    if ( $ARGS{ 'excludes' } ) { 
     
    227229    while ( my $len = sysread( $tar, $buffer, 8192 ) ) { 
    228230        while ( my ( $type, $fh ) = each %{ $self->{ 'writers' } } ) { 
     231            $self->{ 'sigpipeinfo' } = $type; 
    229232            my $written = syswrite( $fh, $buffer, $len ); 
    230233            next if $written == $len; 
    231             $self->clean_and_die( "Writting %u bytes to filehandle for <%s> compression wrote only %u bytes ?!", $len, $written ); 
     234            $self->clean_and_die( "Writting %u bytes to filehandle for <%s> compression wrote only %u bytes ?!", $len, $type, $written ); 
    232235        } 
    233236    } 
     
    384387    $self->log->log( q{pg_start_backup('omnipitr') returned %s.}, $status->{ 'stdout' } ); 
    385388 
     389    $self->{ 'pg_start_backup_done' } = 1; 
     390 
    386391    return; 
    387392} 
     
    396401    my $self          = shift; 
    397402    my @msg_with_args = @_; 
    398     rmtree( $self->{ 'xlogs' } . '.real', $self->{ 'xlogs' } ); 
     403    rmtree( $self->{ 'xlogs' } . '.real', $self->{ 'xlogs' }, { 'verbose' => 0 } ); 
     404    $self->stop_pg_backup() if $self->{ 'pg_start_backup_done' }; 
    399405    $self->log->fatal( @msg_with_args ); 
    400406}