diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2007-06-04 15:56:28 +0000 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2007-06-04 15:56:28 +0000 |
commit | 853d1c3103fa961ae6219f0281885b345593d101 (patch) | |
tree | 464fedaf8f2bd9ee41344e57c4be16ec874155e5 /src/backend/access/gin/ginentrypage.c | |
parent | aae5403278f995e240d956848cdf95fc173693ae (diff) |
Fix bundle bugs of GIN:
- Fix possible deadlock between UPDATE and VACUUM queries. Bug never was
observed in 8.2, but it still exist there. HEAD is more sensitive to
bug after recent "ring" of buffer improvements.
- Fix WAL creation: if parent page is stored as is after split then
incomplete split isn't removed during replay. This happens rather rare, only
on large tables with a lot of updates/inserts.
- Fix WAL replay: there was wrong test of XLR_BKP_BLOCK_* for left
page after deletion of page. That causes wrong rightlink field: it pointed
to deleted page.
- add checking of match of clearing incomplete split
- cleanup incomplete split list after proceeding
All of this chages doesn't change on-disk storage, so backpatch...
But second point may be an issue for replaying logs from previous version.
Diffstat (limited to 'src/backend/access/gin/ginentrypage.c')
-rw-r--r-- | src/backend/access/gin/ginentrypage.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c index 217119b66b3..bf1d8501729 100644 --- a/src/backend/access/gin/ginentrypage.c +++ b/src/backend/access/gin/ginentrypage.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.6 2007/01/05 22:19:21 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.7 2007/06/04 15:56:28 teodor Exp $ *------------------------------------------------------------------------- */ @@ -354,6 +354,7 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd static XLogRecData rdata[3]; OffsetNumber placed; static ginxlogInsert data; + int cnt=0; *prdata = rdata; data.updateBlkno = entryPreparePage(btree, page, off); @@ -371,21 +372,33 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd data.isData = false; data.isLeaf = GinPageIsLeaf(page) ? TRUE : FALSE; - rdata[0].buffer = buf; - rdata[0].buffer_std = TRUE; - rdata[0].data = NULL; - rdata[0].len = 0; - rdata[0].next = &rdata[1]; + /* + * Prevent full page write if child's split occurs. That is needed + * to remove incomplete splits while replaying WAL + * + * data.updateBlkno contains new block number (of newly created right page) + * for recently splited page. + */ + if ( data.updateBlkno == InvalidBlockNumber ) + { + rdata[0].buffer = buf; + rdata[0].buffer_std = TRUE; + rdata[0].data = NULL; + rdata[0].len = 0; + rdata[0].next = &rdata[1]; + cnt++; + } - rdata[1].buffer = InvalidBuffer; - rdata[1].data = (char *) &data; - rdata[1].len = sizeof(ginxlogInsert); - rdata[1].next = &rdata[2]; - - rdata[2].buffer = InvalidBuffer; - rdata[2].data = (char *) btree->entry; - rdata[2].len = IndexTupleSize(btree->entry); - rdata[2].next = NULL; + rdata[cnt].buffer = InvalidBuffer; + rdata[cnt].data = (char *) &data; + rdata[cnt].len = sizeof(ginxlogInsert); + rdata[cnt].next = &rdata[cnt+1]; + cnt++; + + rdata[cnt].buffer = InvalidBuffer; + rdata[cnt].data = (char *) btree->entry; + rdata[cnt].len = IndexTupleSize(btree->entry); + rdata[cnt].next = NULL; btree->entry = NULL; } |