fix-clogredo-pg-r03.diff

text/plain

Filename: fix-clogredo-pg-r03.diff
Type: text/plain
Part: 1
Message: clog_redo causing very long recovery time

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
src/backend/access/transam/clog.c 8 0
diff -cNr postgresql-8.3.13.orig/src/backend/access/transam/clog.c postgresql-8.3.13/src/backend/access/transam/clog.c
*** postgresql-8.3.13.orig/src/backend/access/transam/clog.c	Tue Dec 14 03:51:20 2010
--- postgresql-8.3.13/src/backend/access/transam/clog.c	Thu Apr 28 12:04:52 2011
***************
*** 74,79 ****
--- 75,81 ----
  
  #define ClogCtl (&ClogCtlData)
  
+ static int last_pageno = -1;
  
  static int	ZeroCLOGPage(int pageno, bool writeXlog);
  static bool CLOGPagePrecedes(int page1, int page2);
***************
*** 471,476 ****
--- 476,488 ----
  
  		memcpy(&pageno, XLogRecGetData(record), sizeof(int));
  
+ 		/* avoid repeatedly zeroing the same page */
+ 		if (InRecovery && pageno == last_pageno)
+ 			return;
+ 
+ 		/* save state */
+ 		last_pageno = pageno;
+ 
  		LWLockAcquire(CLogControlLock, LW_EXCLUSIVE);
  
  		slotno = ZeroCLOGPage(pageno, false);