Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id C9BA69FA57B for ; Fri, 26 Oct 2007 09:53:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 72244-03 for ; Fri, 26 Oct 2007 09:53:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from hook.sigaev.ru (nbtest.sai.msu.ru [212.192.243.50]) by postgresql.org (Postfix) with ESMTP id 2983E9FCB0A for ; Fri, 26 Oct 2007 09:53:17 -0300 (ADT) Received: by hook.sigaev.ru (Postfix, from userid 1003) id 4ACD5398E4; Fri, 26 Oct 2007 16:53:15 +0400 (MSD) Received: from xor.sai.msu.ru (xor.sai.msu.ru [212.192.243.97]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by hook.sigaev.ru (Postfix) with ESMTP id 20BC8398E9; Fri, 26 Oct 2007 16:53:09 +0400 (MSD) Message-ID: <4721E335.8090601@sigaev.ru> Date: Fri, 26 Oct 2007 16:53:09 +0400 From: Teodor Sigaev User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.6) Gecko/20070813 SeaMonkey/1.1.4 MIME-Version: 1.0 To: Craig McElroy CC: Tom Lane , PostgreSQL Admin List Subject: Re: Problem with PITR Past Particular WAL File References: <10123.1193250394@sss.pgh.pa.us> <1FAEADD9-FE4A-444E-9B45-D6192B0265E5@contegix.com> <16979.1193327974@sss.pgh.pa.us> <4720DAF9.6080002@sigaev.ru> <4E5ADC27-53C9-4A63-8BE2-7563E2EC89EB@contegix.com> In-Reply-To: <4E5ADC27-53C9-4A63-8BE2-7563E2EC89EB@contegix.com> Content-Type: multipart/mixed; boundary="------------040500020409080602060007" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/263 X-Sequence-Number: 27177 This is a multi-part message in MIME format. --------------040500020409080602060007 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit 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/ --------------040500020409080602060007 Content-Type: text/plain; name="fix_ginstate_usage.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fix_ginstate_usage.patch" *** ./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; } --------------040500020409080602060007--