Re: pg_standby for 8.2 (with last restart point)
От | Gurjeet Singh |
---|---|
Тема | Re: pg_standby for 8.2 (with last restart point) |
Дата | |
Msg-id | 65937bea0805151308o18a696abha5e204bb9b3293d@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: pg_standby for 8.2 (with last restart point) ("Gurjeet Singh" <singh.gurjeet@gmail.com>) |
Список | pgsql-hackers |
On Fri, Mar 28, 2008 at 10:30 AM, Gurjeet Singh <<a href="mailto:singh.gurjeet@gmail.com">singh.gurjeet@gmail.com</a>>wrote:<br /><div class="gmail_quote"><blockquote class="gmail_quote"style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br />Iam still looking for comments on the correctness of this script and above mentioned procedure for running it on an 8.2.xrelease.<br /></blockquote></div><br />Well, I came across a serious bug in the script. Here's the corrected versionof the perl script for anyone who might have picked up the script from here:<br /><br />(Am still looking for anyfeedback on the correctness of the script; especially in the light of the recent possible bugs fixed on the server side,related to recovery)<br /><br /><span style="font-family: courier new,monospace;"><script></span><br style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;">my @text = `</span><span class="nfakPe"style="font-family: courier new,monospace;">pg_controldata</span><span style="font-family: courier new,monospace;">.`; # here . represents the PGDATA, since the server is executing here.</span><br style="font-family: couriernew,monospace;" /><span style="font-family: courier new,monospace;">my $line;</span><br style="font-family: couriernew,monospace;" /><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">my$time_line_id;</span><br style="font-family: courier new,monospace;" /><span style="font-family: couriernew,monospace;"> my $redo_log_id;</span><br style="font-family: courier new,monospace;" /><span style="font-family:courier new,monospace;">my $redo_rec_off;</span><br style="font-family: courier new,monospace;" /><spanstyle="font-family: courier new,monospace;">my $wal_seg_bytes;</span><br style="font-family: courier new,monospace;"/><span style="font-family: courier new,monospace;">my $redo_log_seg;</span><br style="font-family: couriernew,monospace;" /><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">foreach$line ( @text )</span><br style="font-family: courier new,monospace;" /><span style="font-family:courier new,monospace;">{</span><br style="font-family: courier new,monospace;" /><span style="font-family:courier new,monospace;"> $line = mychomp( $line );</span><br style="font-family: courier new,monospace;"/><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;"> if( $line =~ m/Latest checkpoint's TimeLineID:\s*(([0-9])+)/ )</span><br style="font-family: courier new,monospace;"/><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"/><span style="font-family: courier new,monospace;"> # decimal number</span><br style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;"> $time_line_id = 0+ $1;</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;"> }</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;"> if( $line=~ m/Latest checkpoint's REDO location:\s*(([0-9]|[A-F])+)\/</span><span style="font-family: courier new,monospace;">(([0-9]|[A-F])+)/)</span><br style="font-family: courier new,monospace;" /><div class="ArwC7c ckChnd" id="1fzd"><spanstyle="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;" /><spanstyle="font-family: courier new,monospace;"> # hexadecimal numbers</span><br style="font-family: courier new,monospace;"/><span style="font-family: courier new,monospace;"> $redo_log_id = hex( $1 );</span><br style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;"> $redo_rec_off = hex($3 );</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;"> }</span><brstyle="font-family: courier new,monospace;" /><br style="font-family: courier new,monospace;" /><span style="font-family:courier new,monospace;"> if( $line =~ m/Bytes per WAL segment:\s*([0-9]+)/ )</span><br style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;"> {</span><br style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;"> # decimal number</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;"> $wal_seg_bytes= $1;</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">}</span><brstyle="font-family: courier new,monospace;" /><br style="font-family: courier new,monospace;"/><span style="font-family: courier new,monospace;">$redo_log_seg = sprintf( "%d", $redo_rec_off / $wal_seg_bytes);</span><br style="font-family: courier new,monospace;" /><br style="font-family: courier new,monospace;"/><span style="font-family: courier new,monospace;">print "" . sprintf( "%08X%08X%08X", $time_line_id, $redo_log_id,$redo_log_seg ) . "\n";</span><br style="font-family: courier new,monospace;" /><br style="font-family: couriernew,monospace;" /><span style="font-family: courier new,monospace;"># Wrapper around Perl's chomp function</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">sub mychomp</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;">{</span><brstyle="font-family: courier new,monospace;" /><span style="font-family: courier new,monospace;"> my ( $tmp ) = @_;</span><br style="font-family: courier new,monospace;" /><span style="font-family: couriernew,monospace;"> chomp( $tmp );</span><br style="font-family: courier new,monospace;" /><span style="font-family:courier new,monospace;"> return $tmp;</span><br style="font-family: courier new,monospace;" /><spanstyle="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;" /><br style="font-family:courier new,monospace;" /><span style="font-family: courier new,monospace;"></script></span><brstyle="font-family: courier new,monospace;" /><font color="#888888"><br /></font></div><brclear="all" /><br />-- <br />gurjeet[.singh]@EnterpriseDB.com<br />singh.gurjeet@{ gmail | hotmail | indiatimes| yahoo }.com<br /><br />EnterpriseDB <a href="http://www.enterprisedb.com">http://www.enterprisedb.com</a><br/><br />Mail sent from my BlackLaptop device
В списке pgsql-hackers по дате отправления: