Re: pg_standby for 8.2 (with last restart point) - Mailing list pgsql-hackers

From Gurjeet Singh
Subject Re: pg_standby for 8.2 (with last restart point)
Date
Msg-id 65937bea0805151308o18a696abha5e204bb9b3293d@mail.gmail.com
Whole thread Raw
In response to Re: pg_standby for 8.2 (with last restart point)  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
List pgsql-hackers
On Fri, Mar 28, 2008 at 10:30 AM, Gurjeet Singh <singh.gurjeet@gmail.com> wrote:

I am still looking for comments on the correctness of this script and above mentioned procedure for running it on an 8.2.x release.

Well, I came across a serious bug in the script. Here's the corrected version of the perl script for anyone who might have picked up the script from here:

(Am still looking for any feedback on the correctness of the script; especially in the light of the recent possible bugs fixed on the server side, related to recovery)

<script>
my @text = `pg_controldata .`; # here . represents the PGDATA, since the server is executing here.
my $line;

my $time_line_id;
my $redo_log_id;
my $redo_rec_off;
my $wal_seg_bytes;
my $redo_log_seg;

foreach $line ( @text )
{
    $line = mychomp( $line );

    if( $line =~ m/Latest checkpoint's TimeLineID:\s*(([0-9])+)/ )
    {
        # decimal number
        $time_line_id = 0 + $1;
    }
    if( $line =~ m/Latest checkpoint's REDO location:\s*(([0-9]|[A-F])+)\/(([0-9]|[A-F])+)/ )
    {
        # hexadecimal numbers
        $redo_log_id = hex( $1 );
        $redo_rec_off = hex( $3 );
    }

    if( $line =~ m/Bytes per WAL segment:\s*([0-9]+)/ )
    {
        # decimal number
        $wal_seg_bytes = $1;
    }
}

$redo_log_seg = sprintf( "%d", $redo_rec_off / $wal_seg_bytes );

print "" . sprintf( "%08X%08X%08X", $time_line_id, $redo_log_id, $redo_log_seg ) . "\n";

# Wrapper around Perl's chomp function
sub mychomp
{
    my ( $tmp ) = @_;
    chomp( $tmp );
    return $tmp;
}

</script>



--
gurjeet[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

pgsql-hackers by date:

Previous
From: "Marko Kreen"
Date:
Subject: Re: [rfc,patch] PL/Proxy in core
Next
From: Josh Berkus
Date:
Subject: Re: WAL file naming sequence definition