Remove wal_files

Поиск
Список
Период
Сортировка
Искать

Remove wal_files

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
We have the TODO item:

  * Remove wal_files postgresql.conf option because WAL files are now recycled

The following patch completes this item.  It also makes the WAL
documentation a lot easier to understand.  ;-)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.128
diff -c -c -r1.128 runtime.sgml
*** doc/src/sgml/runtime.sgml	29 Aug 2002 19:53:58 -0000	1.128
--- doc/src/sgml/runtime.sgml	30 Aug 2002 03:46:18 -0000
***************
*** 1949,1965 ****
       
  
       
-       WAL_FILES (integer)
-       
-        
-         Number of log files that are created in advance at checkpoint
-         time.  This option can only be set at server start or in the
- 	postgresql.conf file.
-        
-       
-      
- 
-      
        WAL_SYNC_METHOD (string)
        
         
--- 1949,1954 ----
Index: doc/src/sgml/wal.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/wal.sgml,v
retrieving revision 1.16
diff -c -c -r1.16 wal.sgml
*** doc/src/sgml/wal.sgml	5 Jul 2002 19:06:11 -0000	1.16
--- doc/src/sgml/wal.sgml	30 Aug 2002 03:46:18 -0000
***************
*** 276,284 ****
     By default a new 16MB segment file is created only if more than 75% of
     the current segment has been used.  This is inadequate if the system
     generates more than 4MB of log output between checkpoints.
-    One can instruct the server to pre-create up to 64 log segments
-    at checkpoint time by modifying the WAL_FILES
-    configuration parameter.
    
  
    
--- 276,281 ----
***************
*** 306,325 ****
  
    
     The number of 16MB segment files will always be at least
!    WAL_FILES + 1, and will normally not exceed
!    WAL_FILES + MAX(WAL_FILES,
!    CHECKPOINT_SEGMENTS) + 1. This may be used to
!    estimate space requirements for WAL. Ordinarily, when an old log
!    segment files are no longer needed, they are recycled (renamed to
!    become the next sequential future segments). If, due to a short-term
!    peak of log output rate, there are more than
!    WAL_FILES + MAX(WAL_FILES,
!    CHECKPOINT_SEGMENTS) + 1 segment files, then
!    unneeded segment files will be deleted instead of recycled until the
!    system gets back under this limit. (If this happens on a regular
!    basis, WAL_FILES should be increased to avoid it.
!    Deleting log segments that will only have to be created again later
!    is expensive and pointless.)
    
  
    
--- 303,316 ----
  
    
     The number of 16MB segment files will always be at least
!    1, and will normally not exceed CHECKPOINT_SEGMENTS)
!    + 1.  This may be used to estimate space requirements for WAL. 
!    Ordinarily, when old log segment files are no longer needed, 
!    they are recycled (renamed to become the next sequential future 
!    segments). If, due to a short-term peak of log output rate, there 
!    are more than CHECKPOINT_SEGMENTS) + 1 segment files, 
!    the unneeded segment files will be deleted instead of recycled until the
!    system gets back under this limit.
    
  
    
Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/access/transam/xlog.c,v
retrieving revision 1.102
diff -c -c -r1.102 xlog.c
*** src/backend/access/transam/xlog.c	17 Aug 2002 15:12:06 -0000	1.102
--- src/backend/access/transam/xlog.c	30 Aug 2002 03:46:21 -0000
***************
*** 87,93 ****
  /* User-settable parameters */
  int			CheckPointSegments = 3;
  int			XLOGbuffers = 8;
- int			XLOGfiles = 0;		/* # of files to preallocate during ckpt */
  int			XLOG_DEBUG = 0;
  char	   *XLOG_sync_method = NULL;
  const char	XLOG_sync_method_default[] = DEFAULT_SYNC_METHOD_STR;
--- 87,92 ----
***************
*** 97,103 ****
  /*
   * XLOGfileslop is used in the code as the allowed "fuzz" in the number of
   * preallocated XLOG segments --- we try to have at least XLOGfiles advance
!  * segments but no more than XLOGfiles+XLOGfileslop segments.  This could
   * be made a separate GUC variable, but at present I think it's sufficient
   * to hardwire it as 2*CheckPointSegments+1.  Under normal conditions, a
   * checkpoint will free no more than 2*CheckPointSegments log segments, and
--- 96,102 ----
  /*
   * XLOGfileslop is used in the code as the allowed "fuzz" in the number of
   * preallocated XLOG segments --- we try to have at least XLOGfiles advance
!  * segments but no more than XLOGfileslop segments.  This could
   * be made a separate GUC variable, but at present I think it's sufficient
   * to hardwire it as 2*CheckPointSegments+1.  Under normal conditions, a
   * checkpoint will free no more than 2*CheckPointSegments log segments, and
***************
*** 1422,1428 ****
  	 * ours to pre-create a future log segment.
  	 */
  	if (!InstallXLogFileSegment(log, seg, tmppath,
! 								*use_existent, XLOGfiles + XLOGfileslop,
  								use_lock))
  	{
  		/* No need for any more future segments... */
--- 1421,1427 ----
  	 * ours to pre-create a future log segment.
  	 */
  	if (!InstallXLogFileSegment(log, seg, tmppath,
! 								*use_existent, XLOGfileslop,
  								use_lock))
  	{
  		/* No need for any more future segments... */
***************
*** 1568,1587 ****
  	uint32		_logSeg;
  	int			lf;
  	bool		use_existent;
- 	int			i;
  
  	XLByteToPrevSeg(endptr, _logId, _logSeg);
! 	if (XLOGfiles > 0)
! 	{
! 		for (i = 1; i <= XLOGfiles; i++)
! 		{
! 			NextLogSeg(_logId, _logSeg);
! 			use_existent = true;
! 			lf = XLogFileInit(_logId, _logSeg, &use_existent, true);
! 			close(lf);
! 		}
! 	}
! 	else if ((endptr.xrecoff - 1) % XLogSegSize >=
  			 (uint32) (0.75 * XLogSegSize))
  	{
  		NextLogSeg(_logId, _logSeg);
--- 1567,1575 ----
  	uint32		_logSeg;
  	int			lf;
  	bool		use_existent;
  
  	XLByteToPrevSeg(endptr, _logId, _logSeg);
! 	if ((endptr.xrecoff - 1) % XLogSegSize >=
  			 (uint32) (0.75 * XLogSegSize))
  	{
  		NextLogSeg(_logId, _logSeg);
***************
*** 1635,1645 ****
  				/*
  				 * Before deleting the file, see if it can be recycled as
  				 * a future log segment.  We allow recycling segments up
! 				 * to XLOGfiles + XLOGfileslop segments beyond the current
  				 * XLOG location.
  				 */
  				if (InstallXLogFileSegment(endlogId, endlogSeg, path,
! 										   true, XLOGfiles + XLOGfileslop,
  										   true))
  				{
  					elog(LOG, "recycled transaction log file %s",
--- 1623,1633 ----
  				/*
  				 * Before deleting the file, see if it can be recycled as
  				 * a future log segment.  We allow recycling segments up
! 				 * to XLOGfileslop segments beyond the current
  				 * XLOG location.
  				 */
  				if (InstallXLogFileSegment(endlogId, endlogSeg, path,
! 										   true, XLOGfileslop,
  										   true))
  				{
  					elog(LOG, "recycled transaction log file %s",
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v
retrieving revision 1.87
diff -c -c -r1.87 guc.c
*** src/backend/utils/misc/guc.c	29 Aug 2002 21:02:12 -0000	1.87
--- src/backend/utils/misc/guc.c	30 Aug 2002 03:46:23 -0000
***************
*** 641,651 ****
  	},
  
  	{
- 		{ "wal_files", PGC_SIGHUP }, &XLOGfiles,
- 		0, 0, 64, NULL, NULL
- 	},
- 
- 	{
  		{ "wal_debug", PGC_SUSET }, &XLOG_DEBUG,
  		0, 0, 16, NULL, NULL
  	},
--- 641,646 ----
Index: src/include/access/xlog.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/access/xlog.h,v
retrieving revision 1.35
diff -c -c -r1.35 xlog.h
*** src/include/access/xlog.h	17 Aug 2002 15:12:07 -0000	1.35
--- src/include/access/xlog.h	30 Aug 2002 03:46:23 -0000
***************
*** 185,191 ****
  /* these variables are GUC parameters related to XLOG */
  extern int	CheckPointSegments;
  extern int	XLOGbuffers;
- extern int	XLOGfiles;
  extern int	XLOG_DEBUG;
  extern char *XLOG_sync_method;
  extern const char XLOG_sync_method_default[];
--- 185,190 ----
FAQ