WIP archive_timeout.

All we need to do is add LWLock support to archiver.
Thoughts/ideas/hints welcome.

This is a patch-on-patch atop the xswitch.patch recently posted.

-- 
  Simon Riggs
  EnterpriseDB          http://www.enterprisedb.com
Index: doc/src/sgml/backup.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/backup.sgml,v
retrieving revision 2.81
diff -c -r2.81 backup.sgml
*** doc/src/sgml/backup.sgml	18 Jun 2006 15:38:35 -0000	2.81
--- doc/src/sgml/backup.sgml	31 Jul 2006 20:34:25 -0000
***************
*** 573,600 ****
      the <filename>pg_xlog/</> directory will contain large numbers of
      not-yet-archived segment files, which could eventually exceed available
      disk space. You are advised to monitor the archiving process to ensure that
!     it is working as you intend.
     </para>
  
     <para>
!     If you are concerned about being able to recover right up to the
!     current instant, you may want to take additional steps to ensure that
!     the current, partially-filled WAL segment is also copied someplace.
!     This is particularly important if your server generates only little WAL
!     traffic (or has slack periods where it does so), since it could take a
!     long time before a WAL segment file is completely filled and ready to
!     archive.  One possible way to handle this is to set up a
!     <application>cron</> job that periodically (once a minute, perhaps)
!     identifies the current WAL segment file and saves it someplace safe.
!     Then the combination of the archived WAL segments and the saved current
!     segment will be enough to ensure you can always restore to within a
!     minute of current time.  This behavior is not presently built into
!     <productname>PostgreSQL</> because we did not want to complicate the
!     definition of the <xref linkend="guc-archive-command"> by requiring it
!     to keep track of successively archived, but different, copies of the
!     same WAL file.  The <xref linkend="guc-archive-command"> is only
!     invoked on completed WAL segments. Except in the case of retrying a
!     failure, it will be called only once for any given file name.
     </para>
  
     <para>
--- 573,593 ----
      the <filename>pg_xlog/</> directory will contain large numbers of
      not-yet-archived segment files, which could eventually exceed available
      disk space. You are advised to monitor the archiving process to ensure that
!     it is working as you intend. 
     </para>
  
     <para>
!     The <xref linkend="guc-archive-command"> is only invoked on completed 
!     WAL segments. This could lead to delays in producing the next archive
!     if your server generates only little WAL traffic (or has slack periods 
!     where it does so). To ensure regular archives are produced you can 
!     specify an <xref linkend="guc-archive-timeout"> which will automatically
!     switch to a new WAL segment file during quieter periods. Archived files
!     produced in this way are still the same length as completely full files,
!     though entries made after the final processing instruction can be ignored.
!     Switching to a new WAL segment file can be performed manually using
!     <function>pg_switch_xlog</>. A variety of other utility functions are
!     also available, listed in <xref linkend="functions-admin-backup-table">
     </para>
  
     <para>
Index: doc/src/sgml/config.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/config.sgml,v
retrieving revision 1.71
diff -c -r1.71 config.sgml
*** doc/src/sgml/config.sgml	27 Jul 2006 08:30:41 -0000	1.71
--- doc/src/sgml/config.sgml	31 Jul 2006 20:34:31 -0000
***************
*** 1586,1591 ****
--- 1586,1614 ----
        </listitem>
       </varlistentry>
       
+      <varlistentry id="guc-archive-timeout" xreflabel="archive_timeout">
+       <term><varname>archive_timeout</varname> (<type>string</type>)</term>
+       <indexterm>
+        <primary><varname>archive_timeout</> configuration parameter</primary>
+       </indexterm>
+       <listitem>
+        <para>
+         The <xref linkend="guc-archive-command"> is only invoked on completed 
+         WAL segments. This could lead to delays in producing the next archive
+         if your server generates only little WAL traffic (or has slack periods 
+         where it does so). This parameter provides regular archiving by
+         making sure that no more than <xref linkend="guc-archive-command">
+         go by before a new WAL segment file is produced for archiving, even
+         if that means we archive a partially filled file. Zero disables this
+         feature, which is the default Valid values are from 1 to 60 seconds.
+         This parameter can only be set in the <filename>postgresql.conf</>
+         file or on the server command line. Be careful to set 
+         <varname>checkpoint_segments</> sufficiently high that you do not
+         inadvertently increase the rate at which checkpoints occur.
+        </para>
+       </listitem>
+      </varlistentry>
+      
       </variablelist>
      </sect2>
     </sect1>
Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xlog.c,v
retrieving revision 1.244
diff -c -r1.244 xlog.c
*** src/backend/access/transam/xlog.c	14 Jul 2006 14:52:17 -0000	1.244
--- src/backend/access/transam/xlog.c	31 Jul 2006 20:34:50 -0000
***************
*** 127,132 ****
--- 127,133 ----
  /* User-settable parameters */
  int			CheckPointSegments = 3;
  int			XLOGbuffers = 8;
+ int         XLogArchiveTimeout = 0;
  char	   *XLogArchiveCommand = NULL;
  char	   *XLOG_sync_method = NULL;
  const char	XLOG_sync_method_default[] = DEFAULT_SYNC_METHOD_STR;
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.333
diff -c -r1.333 guc.c
*** src/backend/utils/misc/guc.c	29 Jul 2006 03:02:56 -0000	1.333
--- src/backend/utils/misc/guc.c	31 Jul 2006 20:34:57 -0000
***************
*** 1020,1025 ****
--- 1020,1034 ----
  static struct config_int ConfigureNamesInt[] =
  {
  	{
+ 		{"archive_timeout", PGC_SIGHUP, WAL_SETTINGS,
+ 		 gettext_noop("Will force a switch to the next xlog file if a new file has not "
+                       "been started within N seconds."),
+ 		 gettext_noop("This allows regular continuous archiving to take place.")
+ 		},
+ 		&XLogArchiveTimeout,
+ 		0, 0, 60, NULL, NULL
+ 	},
+ 	{
  		{"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
  		 gettext_noop("Waits N seconds on connection startup after authentication."),
  		 gettext_noop("This allows attaching a debugger to the process."),
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.184
diff -c -r1.184 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample	25 Jul 2006 03:51:21 -0000	1.184
--- src/backend/utils/misc/postgresql.conf.sample	31 Jul 2006 20:34:57 -0000
***************
*** 167,174 ****
  
  # - Archiving -
  
! #archive_command = ''			# command to use to archive a logfile 
! 					# segment
  
  
  #---------------------------------------------------------------------------
--- 167,176 ----
  
  # - Archiving -
  
! # command to use to archive a logfile segment
! #archive_command = ''		
! #archive_timeout = 0        # automatic xlog switch gives regular archiving
!                             # range 0-60 in seconds, 0 is off 
  
  
  #---------------------------------------------------------------------------
Index: src/include/access/xlog.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/access/xlog.h,v
retrieving revision 1.72
diff -c -r1.72 xlog.h
*** src/include/access/xlog.h	13 Jul 2006 16:49:19 -0000	1.72
--- src/include/access/xlog.h	31 Jul 2006 20:34:58 -0000
***************
*** 139,144 ****
--- 139,145 ----
  extern int	CheckPointSegments;
  extern int	XLOGbuffers;
  extern char *XLogArchiveCommand;
+ extern int XLogArchiveTimeout;
  extern char *XLOG_sync_method;
  extern const char XLOG_sync_method_default[];
  
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to