Changeset 248

Show
Ignore:
Timestamp:
06/24/11 15:16:22 (3 years ago)
Author:
depesz
Message:

more debug info

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tools/fast.dump.and.restore/fast.dump

    r247 r248  
    2020use File::Temp qw( tempfile ); 
    2121 
    22 our @killed_pids = (); 
     22our %killed_pids = (); 
    2323 
    2424sub REAPER { 
    2525    my $child; 
    2626    while ( ( $child = waitpid( -1, WNOHANG ) ) > 0 ) { 
    27         push @killed_pids, $child
     27        $killed_pids{ $child } = time()
    2828    } 
    2929    $SIG{ 'CHLD' } = \&REAPER; 
     
    6969    } 
    7070 
    71     open my $fh, ">", File::Spec->catfile( $self->{'output'}, 'index.lst' ) or croak( "Cannot create index file: $OS_ERROR\n" ); 
    72     print $fh Dumper( $self->{ 'blobs' } ); 
    73     close $fh; 
     71    open my $fh, ">", File::Spec->catfile( $self->{ 'output' }, 'index.lst' ) or croak( "Cannot create index file: $OS_ERROR\n" ); 
     72    printf $fh '%-5s | %-7s | %-32s | %-32s | %s%s', qw( # type schema table condition ), "\n"; 
     73    for my $i ( @{ $self->{'blobs'} } ) { 
     74        printf $fh '%5d | %-7s | %-32s | %-32s | %s%s', @{ $i }{ qw( id blob_type schema table ) }, ( $i->{'condition'} || '' ), "\n"; 
     75    } 
    7476 
    7577    printf "%d blobs to be processed. %d full and %d partial.\n", @c{ qw( total full partial ) }; 
    7678    my %running_kids = (); 
    7779    while ( 1 ) { 
    78         while ( my $killed = shift @killed_pids ) { 
    79             delete $running_kids{ $killed }; 
     80        my @pids = keys %killed_pids; 
     81        for my $killed ( @pids ) { 
     82            my $blob     = delete $running_kids{ $killed }; 
     83            my $end_time = delete $killed_pids{ $killed }; 
     84            printf $fh "%s dump (#%d) of %s.%s finished after %d seconds.\n", $blob->{ 'blob_type' }, $blob->{ 'id' }, $blob->{ 'schema' }, $blob->{ 'table' }, $end_time - $blob->{ 'started' }; 
    8085        } 
    8186        while ( $self->{ 'jobs' } > scalar keys %running_kids ) { 
     
    9398 
    9499            # It's master. 
     100            $blob->{ 'started' } = time(); 
    95101            $running_kids{ $pid } = $blob; 
    96102        } 
     
    363369 
    364370    my $largest_tables = $self->psql( 
    365 "SELECT * FROM ( SELECT rpad(oid::regclass::text, 32) || ' (' || pg_size_pretty(pg_relation_size(oid)) || ')' from pg_class where relkind = 'r' order by pg_relation_size(oid) desc limit 5) x order by 1" 
     371"SELECT * FROM ( SELECT rpad(oid::regclass::text, 32) || ' (' || pg_size_pretty(pg_relation_size(oid)) || ')' from pg_class where relkind = 'r' and relname !~ '^pg_' order by pg_relation_size(oid) desc limit 5) x order by 1" 
    366372    ); 
    367373