Re: [PATCHES] [HACKERS] Suggestion: Which Binary?

2006-04-25 Thread David Wheeler

On Apr 25, 2006, at 08:19, Bruce Momjian wrote:


I have applied the attached patch, and updated descriptions for the
items you were uncertain of.  I didn't add defaults for some of
the more unusual entries, but just left them blank.


Cool, thank you, Bruce.

Best,

David

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [PATCHES] [HACKERS] For Review: Allow WAL information to recover corrupted

2006-04-25 Thread Bruce Momjian

Patch attached and applied, with documentation additions.  Thanks.

---

yuanjia lee wrote:
 
 Hi All
 
 I had added an option -r to pg_resetxlog to enable the tool can rebuild the 
 corrupted pg_control file from the old xlog files. 
 
 here is the patch. Sorry I had tried to attached it to the mail, but it 
 failed, I dont know why, here is the 
 link:http://www.geocities.com/yuanjia_pg/pg_resetxlog.diff.txt
 
 There are also some changes in the logic of other options.
 Option -n: only print out the control values in the existing pg_control file, 
 if the file is corrupted , inform the use to rebuild it first only.
 Option -f: if pg_control file is fine, then reset the xlog file; if 
 pg_control is corrupted , then try to rebuild the control file from old xlog 
 file, if it fails, then just guessing the value, then reset the xlog file.
 
  The algorithm of restoring the pg_control value from old xlog file:
  1. Retrieve all of the active xlog files from xlog directory into a list by 
 increasing order, according their timeline, log id, segment id. (Tom had 
 informed me that we can not know which segment file is latest just by the 
 name itself, so before adding the segment file to the list, it should be 
 checked that it is an active segment file.)
 2. Search the list to find the oldest xlog file of the latest time line. 
 (Although it is better to let the user to select the time line which is used 
 for rebuild the xlog file, but I think there is not so necessary. I had tried 
 to use only the last file in the latest time line, but I found that in many 
 cases, there are possible that the last checkpoint record and the previous 
 checkpoint record are stored separately in different segment file, so I had 
 to search from the oldest one.)
 3. Search the records from the oldest xlog file of latest time line to the 
 latest xlog file of latest time line, if the checkpoint record has been 
 found, update the latest checkpoint and previous checkpoint. 
 
 Some of the code is borrowed from Tom Lane xlogdump.c file.
 
 Hope for your advice.
 
 Best Regards
 Yuanjia Lee
 
 
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around 
 http://mail.yahoo.com 

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDBhttp://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/ref/pg_resetxlog.sgml
===
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/pg_resetxlog.sgml,v
retrieving revision 1.13
diff -c -c -r1.13 pg_resetxlog.sgml
*** doc/src/sgml/ref/pg_resetxlog.sgml  25 Apr 2006 21:02:33 -  1.13
--- doc/src/sgml/ref/pg_resetxlog.sgml  26 Apr 2006 02:14:43 -
***
*** 20,25 
--- 20,26 
 commandpg_resetxlog/command
 arg-f/arg
 arg-n/arg
+arg-r/arg
 arg-oreplaceable class=parameteroid/replaceable /arg
 arg-x replaceable class=parameterxid/replaceable /arg
 arg-m replaceable class=parametermxid/replaceable /arg
***
*** 57,78 
  
para
 If commandpg_resetxlog/command complains that it cannot determine
!valid data for filenamepg_control/, you can force it to proceed anyway
!by specifying the literal-f/ (force) switch.  In this case plausible
!values will be substituted for the missing data.  Most of the fields can be
!expected to match, but manual assistance may be needed for the next OID,
!next transaction ID, next multitransaction ID and offset,
!WAL starting address, and database locale fields.
!The first five of these can be set using the switches discussed below.
!commandpg_resetxlog/command's own environment is the source for its
!guess at the locale fields; take care that envarLANG/ and so forth
!match the environment that commandinitdb/ was run in.
!If you are not able to determine correct values for all these fields,
!literal-f/ can still be used, but
 the recovered database must be treated with even more suspicion than
!usual: an immediate dump and reload is imperative.  emphasisDo not/
!execute any data-modifying operations in the database before you dump;
!as any such action is likely to make the corruption worse.
/para
  
para
--- 58,79 
  
para
 If commandpg_resetxlog/command complains that it cannot determine
!valid data for filenamepg_control/, you can force it to proceed
!anyway by specifying the literal-f/ (force) switch. In this case
!plausible values will be substituted for the missing data.
!commandpg_resetxlog/command's own environment is the source for
!its guess at the locale fields; take care that envarLANG/ and so
!forth match the environment that commandinitdb/ was run in.
!filename/xlog/ files are used to determine other parameters, like
!