Re: Problem with PITR Past Particular WAL File - Mailing list pgsql-admin

From Teodor Sigaev
Subject Re: Problem with PITR Past Particular WAL File
Date
Msg-id 4721E335.8090601@sigaev.ru
Whole thread Raw
In response to Re: Problem with PITR Past Particular WAL File  (Craig McElroy <craig.mcelroy@contegix.com>)
List pgsql-admin

Craig McElroy wrote:
> Teodor:
>   Thanks for the followup.  We will be upgrading this system to 8.2.5 in
> the next day or so and will test it on that anyways just to be sure it
> isn't related.  Let me know if there is anything else we can provide to
> help track down the bug.  We will be keeping this base backup and WAL
> files around so that we can use them for testing.
If I'm right then 8.2.5 will not help you. Attached patch should fix your
problem, but I suppose that there is an another bug. Test specially developed
for reproduce your problem discovers another issue. The diagnostic is:
FATAL:  failed to add item to index page in 1663/10819/16460
CONTEXT:  xlog redo Insert item, node: 1663/10819/16460 blkno: 514 offset: 78
nitem: 1 isdata: F isleaf F isdelete F updateBlkno:1551

Now I'm working on fixing it.
--
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                    WWW: http://www.sigaev.ru/
*** ./src/backend/access/gin.orig/ginentrypage.c    Thu Oct 25 22:11:56 2007
--- ./src/backend/access/gin/ginentrypage.c    Thu Oct 25 22:43:17 2007
***************
*** 404,409 ****
--- 404,434 ----
  }

  /*
+  * Returns new tuple with copied value from source tuple.
+  * New tuple will not store posting list
+  */
+ static IndexTuple
+ copyIndexTuple(IndexTuple itup, Page page)
+ {
+     IndexTuple    nitup;
+
+     if (GinPageIsLeaf(page) && !GinIsPostingTree(itup))
+     {
+         nitup = (IndexTuple) palloc(MAXALIGN(GinGetOrigSizePosting(itup)));
+         memcpy(nitup, itup, GinGetOrigSizePosting(itup));
+         nitup->t_info &= ~INDEX_SIZE_MASK;
+         nitup->t_info |= GinGetOrigSizePosting(itup);
+     }
+     else
+     {
+         nitup = (IndexTuple) palloc(MAXALIGN(IndexTupleSize(itup)));
+         memcpy(nitup, itup, IndexTupleSize(itup));
+     }
+
+     return nitup;
+ }
+
+ /*
   * Place tuple and split page, original buffer(lbuf) leaves untouched,
   * returns shadow page of lbuf filled new data.
   * Tuples are distributed between pages by equal size on its, not
***************
*** 424,431 ****
      IndexTuple    itup,
                  leftrightmost = NULL;
      static ginxlogSplit data;
-     Datum        value;
-     bool        isnull;
      Page        page;
      Page        lpage = GinPageGetCopyPage(BufferGetPage(lbuf));
      Page        rpage = BufferGetPage(rbuf);
--- 449,454 ----
***************
*** 494,502 ****
          ptr += MAXALIGN(IndexTupleSize(itup));
      }

!     value = index_getattr(leftrightmost, FirstOffsetNumber, btree->ginstate->tupdesc, &isnull);
!     btree->entry = GinFormTuple(btree->ginstate, value, NULL, 0);
      ItemPointerSet(&(btree->entry)->t_tid, BufferGetBlockNumber(lbuf), InvalidOffsetNumber);
      btree->rightblkno = BufferGetBlockNumber(rbuf);

      data.node = btree->index->rd_node;
--- 517,525 ----
          ptr += MAXALIGN(IndexTupleSize(itup));
      }

!     btree->entry = copyIndexTuple(leftrightmost, lpage);
      ItemPointerSet(&(btree->entry)->t_tid, BufferGetBlockNumber(lbuf), InvalidOffsetNumber);
+
      btree->rightblkno = BufferGetBlockNumber(rbuf);

      data.node = btree->index->rd_node;
***************
*** 533,552 ****
      Page        page = BufferGetPage(buf);

      itup = getRightMostTuple(page);
!     if (GinPageIsLeaf(page) && !GinIsPostingTree(itup))
!     {
!         nitup = (IndexTuple) palloc(MAXALIGN(GinGetOrigSizePosting(itup)));
!         memcpy(nitup, itup, GinGetOrigSizePosting(itup));
!         nitup->t_info &= ~INDEX_SIZE_MASK;
!         nitup->t_info |= GinGetOrigSizePosting(itup);
!     }
!     else
!     {
!         nitup = (IndexTuple) palloc(MAXALIGN(IndexTupleSize(itup)));
!         memcpy(nitup, itup, IndexTupleSize(itup));
!     }
!
      ItemPointerSet(&nitup->t_tid, BufferGetBlockNumber(buf), InvalidOffsetNumber);
      return nitup;
  }

--- 556,564 ----
      Page        page = BufferGetPage(buf);

      itup = getRightMostTuple(page);
!     nitup = copyIndexTuple(itup, page);
      ItemPointerSet(&nitup->t_tid, BufferGetBlockNumber(buf), InvalidOffsetNumber);
+
      return nitup;
  }


pgsql-admin by date:

Previous
From: "Dawid Kuroczko"
Date:
Subject: Re: 32-bit to 64-bit migration screwup
Next
From: yogesh
Date:
Subject: PL/JAVA installation on Suse Linux