Re: Tracking down log segment corruption - Mailing list pgsql-general

From Tom Lane
Subject Re: Tracking down log segment corruption
Date
Msg-id 19434.1272839395@sss.pgh.pa.us
Whole thread Raw
In response to Re: Tracking down log segment corruption  (Gordon Shannon <gordo169@gmail.com>)
List pgsql-general
Gordon Shannon <gordo169@gmail.com> writes:
> In any case, I will cease and desist from ALTER SET TABLESPACE for a while!.

Here's the applied patch, if you are interested in testing it.

            regards, tom lane

Index: src/backend/access/heap/heapam.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v
retrieving revision 1.277.2.1
diff -c -r1.277.2.1 heapam.c
*** src/backend/access/heap/heapam.c    24 Aug 2009 02:18:40 -0000    1.277.2.1
--- src/backend/access/heap/heapam.c    2 May 2010 22:19:04 -0000
***************
*** 4195,4202 ****
       * Note: the NEWPAGE log record is used for both heaps and indexes, so do
       * not do anything that assumes we are touching a heap.
       */
!     buffer = XLogReadBuffer(xlrec->node, xlrec->blkno, true);
      Assert(BufferIsValid(buffer));
      page = (Page) BufferGetPage(buffer);

      Assert(record->xl_len == SizeOfHeapNewpage + BLCKSZ);
--- 4195,4204 ----
       * Note: the NEWPAGE log record is used for both heaps and indexes, so do
       * not do anything that assumes we are touching a heap.
       */
!     buffer = XLogReadBufferExtended(xlrec->node, xlrec->forknum, xlrec->blkno,
!                                     RBM_ZERO);
      Assert(BufferIsValid(buffer));
+     LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
      page = (Page) BufferGetPage(buffer);

      Assert(record->xl_len == SizeOfHeapNewpage + BLCKSZ);

pgsql-general by date:

Previous
From: Gordon Shannon
Date:
Subject: Re: Tracking down log segment corruption
Next
From: Thomas Løcke
Date:
Subject: Re: PostgreSQL vs. Microsoft SQL server