On Fri, 2008-03-28 at 00:54 -0400, Tom Lane wrote: > Greg Smith <[EMAIL PROTECTED]> writes: > > ... That was a small change in a utility that should never be run on a > > production system. You're trying to get a change made to the code path > > people rely on for their *backups*. Good luck with that. > > While I quite agree with Greg's comments about not changing stable > release branches unnecessarily, it seems that there's another > consideration in this case. If we don't back-patch %r then users > will have to rely on hacky scripts like the one posted upthread. > Is that really a net gain in reliability? > > (I'm honestly not sure of the answer; I'm just thinking it might > be open to debate. In particular I don't remember how complicated > the patch to add %r was.)
Here's the original patch, edited to remove pg_standby changes. I've not even checked whether it will apply, but it seems fairly simple. Gurjeet, would you like to freshen and test that up for apply to 8.2? -- Simon Riggs 2ndQuadrant http://www.2ndQuadrant.com PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk
Index: doc/src/sgml/backup.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/backup.sgml,v retrieving revision 2.97 diff -c -r2.97 backup.sgml *** doc/src/sgml/backup.sgml 1 Feb 2007 00:28:16 -0000 2.97 --- doc/src/sgml/backup.sgml 9 Feb 2007 23:05:26 -0000 *************** *** 526,531 **** --- 526,536 ---- archive, while any <literal>%f</> is replaced by the file name only. (The path name is relative to the working directory of the server, i.e., the cluster's data directory.) + A <literal>%r</> will be replaced by the name of the file containing + the last valid restartpoint. This is the earliest file that must be + kept to allow a restore to be restartable, so this information can + allow if the archive to be truncated to just the minimum required + to support restart of the current restore. Write <literal>%%</> if you need to embed an actual <literal>%</> character in the command. The simplest useful command is something like: *************** *** 922,927 **** --- 927,937 ---- which is replaced by the path name to copy the log file to. (The path name is relative to the working directory of the server, i.e., the cluster's data directory.) + A <literal>%r</> will be replaced by the name of the file containing + the last valid restartpoint. This is the earliest file that must be + kept to allow a restore to be restartable, so this information can + allow if the archive to be truncated to just the minimum required + to support restart of the current restore. Write <literal>%%</> if you need to embed an actual <literal>%</> character in the command. The simplest useful command is something like: *************** *** 1008,1020 **** <listitem> <para> The shell command to execute to retrieve an archived segment of ! the WAL file series. This parameter is required. ! Any <literal>%f</> in the string is ! replaced by the name of the file to retrieve from the archive, ! and any <literal>%p</> is replaced by the path name to copy ! it to on the server. ! (The path name is relative to the working directory of the server, ! i.e., the cluster's data directory.) Write <literal>%%</> to embed an actual <literal>%</> character in the command. </para> --- 1018,1033 ---- <listitem> <para> The shell command to execute to retrieve an archived segment of ! the WAL file series. This parameter is required. Any <literal>%f</> ! in the string is replaced by the name of the file to retrieve from ! the archive, and any <literal>%p</> is replaced by the path name to ! copy it to on the server. (The path name is relative to the working ! directory of the server, i.e., the cluster's data directory.) ! A <literal>%r</> will be replaced by the name of the file containing ! the last valid restartpoint. This is the earliest file that must be ! kept to allow a restore to be restartable, so this information can ! allow if the archive to be truncated to just the minimum required ! to support restart of the current restore. Write <literal>%%</> to embed an actual <literal>%</> character in the command. </para> *************** *** 1024,1031 **** names that are not present in the archive; it must return nonzero when so asked. Examples: <programlisting> ! restore_command = 'cp /mnt/server/archivedir/%f "%p"' ! restore_command = 'copy /mnt/server/archivedir/%f "%p"' # Windows </programlisting> </para> </listitem> --- 1037,1044 ---- names that are not present in the archive; it must return nonzero when so asked. Examples: <programlisting> ! restore_command = 'cp /mnt/server/archivedir/%f "%p" "%r"' ! restore_command = 'copy /mnt/server/archivedir/%f "%p" "%r"' # Windows </programlisting> </para> </listitem> *************** *** 1374,1380 **** contact between the two database servers is the archive of WAL files that both share: primary writing to the archive, standby reading from the archive. Care must be taken to ensure that WAL archives for separate ! primary servers do not become mixed together or confused. </para> <para> --- 1387,1394 ---- contact between the two database servers is the archive of WAL files that both share: primary writing to the archive, standby reading from the archive. Care must be taken to ensure that WAL archives for separate ! primary servers do not become mixed together or confused. The archive ! need not be large, if it is only required to the standby operation. </para> <para> *************** *** 1434,1439 **** --- 1448,1466 ---- as the explicit creation of a trigger file is less error prone, if this can be arranged. </para> + + <para> + A working version of a wait-for <varname>restore_command</> is provided + as a contrib module, known as <applications>pg_standby</>. This can be + extended as needed to support specific configurations or environments. + </para> + + <para> + The size of the WAL archive can be minimised by using the <literal>%r</> + option of the <varname>restore_command</>. This option specifies the + last archive filename that needs to be kept to allow the recovery to + restart correctly. This can be used to truncate the archive once + files are no longer required. </sect2> <sect2 id="warm-standby-config"> Index: src/backend/access/transam/xlog.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xlog.c,v retrieving revision 1.263 diff -c -r1.263 xlog.c *** src/backend/access/transam/xlog.c 8 Feb 2007 11:10:27 -0000 1.263 --- src/backend/access/transam/xlog.c 9 Feb 2007 23:05:34 -0000 *************** *** 190,195 **** --- 190,196 ---- static TransactionId recoveryStopXid; static time_t recoveryStopTime; static bool recoveryStopAfter; + static char lastRestorepointFname[MAXFNAMELEN]; /* * During normal operation, the only timeline we care about is ThisTimeLineID. *************** *** 2359,2364 **** --- 2360,2366 ---- { char xlogpath[MAXPGPATH]; char xlogRestoreCmd[MAXPGPATH]; + char lastRestartPointFname[MAXPGPATH]; char *dp; char *endp; const char *sp; *************** *** 2437,2442 **** --- 2439,2454 ---- StrNCpy(dp, xlogfname, endp - dp); dp += strlen(dp); break; + case 'r': + /* %r: filename of last restartpoint */ + sp++; + XLogFileName(lastRestartPointFname, + ControlFile->checkPointCopy->ThisTimelineId, + ControlFile->checkPointCopy->redo.xlogid, + ControlFile->checkPointCopy->redo.xrecoff); + StrNCpy(dp, lastRestartPointFname, endp - dp); + dp += strlen(dp); + break; case '%': /* convert %% to a single % */ sp++;
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers