GIN stuck in loop during PITR

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

GIN stuck in loop during PITR

От:
Andreas Seltenreich <andreas+pg@gate450.dyndns.org>
Дата:
I'm just experimenting a bit with GIN, and it is occasionally getting
stuck looping in findParents() during WAL replay.

The attached patch seems to fix it. I also had to set ptr->off as
advertised in the comment above the function to avoid triggering
assertions.

GIN isn't fully transparent to me yet, so it is quite likely that I am
missing something...

regards,
andreas

Index: ginbtree.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/gin/ginbtree.c,v
retrieving revision 1.1
diff -c -r1.1 ginbtree.c
*** ginbtree.c	2 May 2006 11:28:54 -0000	1.1
--- ginbtree.c	25 May 2006 18:12:13 -0000
***************
*** 202,208 **** 	for(;;) { 		buffer = ReadBuffer(btree->index, blkno); 		LockBuffer(buffer, GIN_EXCLUSIVE);
! 		page = BufferGetPage(root->buffer); 		if ( GinPageIsLeaf(page) ) 			elog(ERROR, "Lost path"); 
--- 202,208 ---- 	for(;;) { 		buffer = ReadBuffer(btree->index, blkno); 		LockBuffer(buffer, GIN_EXCLUSIVE);
! 		page = BufferGetPage(buffer); 		if ( GinPageIsLeaf(page) ) 			elog(ERROR, "Lost path"); 
***************
*** 224,229 ****
--- 224,230 ---- 			ptr->blkno = blkno; 			ptr->buffer = buffer; 			ptr->parent = root; /* it's may be wrong, but in next call we will correct */
+ 			ptr->off = offset; 			stack->parent = ptr; 			return; 		}

Re: GIN stuck in loop during PITR

От:
Teodor Sigaev <teodor@sigaev.ru>
Дата:
Thanks a lot, applied. Can you describe test suite? It may be useful for test 
more...

GIN is young code and it needs to independently tests.

Andreas Seltenreich wrote:
> I'm just experimenting a bit with GIN, and it is occasionally getting
> stuck looping in findParents() during WAL replay.
-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru                                                   WWW: http://www.sigaev.ru/

Re: GIN stuck in loop during PITR

От:
Andreas Seltenreich <andreas+pg@gate450.dyndns.org>
Дата:
Teodor Sigaev schrob:

> Thanks a lot, applied. Can you describe test suite? It may be useful
> for test more...

Here's a shell script that triggers the bug when I revert the patch.

regards,
andreas

#!/bin/sh

set -x
set -e

PGPORT=5434
CLUSTER="gintest/"
ARCHIVE="gintest-archive/"

[ -d "$ARCHIVE" ] || mkdir "$ARCHIVE"

initdb -D $CLUSTER
cat >> $CLUSTER/postgresql.conf <> "$CLUSTER/recovery.conf" <

Re: GIN stuck in loop during PITR

От:
Andreas Seltenreich <andreas+pg@gate450.dyndns.org>
Дата:
Andreas Seltenreich schrob:

> Teodor Sigaev schrob:
>
>> Thanks a lot, applied. Can you describe test suite? It may be useful
>> for test more...
>
> Here's a shell script that triggers the bug when I revert the patch.

Just tried the script on HEAD, and it was triggering an assertion. I
guess it is because we are still returning InvalidOffsetNumber in the
trivial case (looks like a typo to me). I've attached a patch.

regards,
andreas

Index: ginbtree.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/gin/ginbtree.c,v
retrieving revision 1.2
diff -c -r1.2 ginbtree.c
*** ginbtree.c	26 May 2006 08:01:17 -0000	1.2
--- ginbtree.c	26 May 2006 20:09:45 -0000
***************
*** 189,195 **** 	Assert( !GinPageIsLeaf(page) );  	/* check trivial case */
! 	if ( (root->off != btree->findChildPtr(btree, page, stack->blkno, InvalidOffsetNumber)) != InvalidBuffer ) { 		stack->parent = root; 		return; 	}
--- 189,195 ---- 	Assert( !GinPageIsLeaf(page) );  	/* check trivial case */
! 	if ( (root->off = btree->findChildPtr(btree, page, stack->blkno, InvalidOffsetNumber)) != InvalidOffsetNumber ) { 		stack->parent = root; 		return; 	}

FAQ