Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6acb95

Browse files
committed
Fix full-page writes of internal GIN pages.
Insertion to a non-leaf GIN page didn't make a full-page image of the page,which is wrong. The code used to do it correctly, but was changed (commit853d1c3) because the redo-routine didn'ttrack incomplete splits correctly when the page was restored from a fullpage image. Of course, that was not right way to fix it, the redo routineshould've been fixed instead. The redo-routine was surreptitiously fixedin 2010 (commit4016bde), so all we needto do now is revert the code that creates the record to its original form.This doesn't change the format of the WAL record.Backpatch to all supported versions.
1 parentf67b8ae commite6acb95

File tree

2 files changed

+34
-50
lines changed

2 files changed

+34
-50
lines changed

‎src/backend/access/gin/gindatapage.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ dataPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prda
382382
{
383383
Pagepage=BufferGetPage(buf);
384384
intsizeofitem=GinSizeOfDataPageItem(page);
385-
intcnt=0;
386385

387386
/* these must be static so they can be returned to caller */
388387
staticXLogRecDatardata[3];
@@ -402,32 +401,25 @@ dataPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prda
402401
data.isLeaf=GinPageIsLeaf(page) ? TRUE : FALSE;
403402

404403
/*
405-
* Prevent full page write if child's split occurs. That is needed to
406-
* remove incomplete splits while replaying WAL
407-
*
408-
* data.updateBlkno contains new block number (of newly created right
409-
* page) for recently splited page.
404+
* For incomplete-split tracking, we need updateBlkno information and the
405+
* inserted item even when we make a full page image of the page, so put
406+
* the buffer reference in a separate XLogRecData entry.
410407
*/
411-
if (data.updateBlkno==InvalidBlockNumber)
412-
{
413-
rdata[0].buffer=buf;
414-
rdata[0].buffer_std= FALSE;
415-
rdata[0].data=NULL;
416-
rdata[0].len=0;
417-
rdata[0].next=&rdata[1];
418-
cnt++;
419-
}
408+
rdata[0].buffer=buf;
409+
rdata[0].buffer_std= FALSE;
410+
rdata[0].data=NULL;
411+
rdata[0].len=0;
412+
rdata[0].next=&rdata[1];
420413

421-
rdata[cnt].buffer=InvalidBuffer;
422-
rdata[cnt].data= (char*)&data;
423-
rdata[cnt].len=sizeof(ginxlogInsert);
424-
rdata[cnt].next=&rdata[cnt+1];
425-
cnt++;
414+
rdata[1].buffer=InvalidBuffer;
415+
rdata[1].data= (char*)&data;
416+
rdata[1].len=sizeof(ginxlogInsert);
417+
rdata[1].next=&rdata[2];
426418

427-
rdata[cnt].buffer=InvalidBuffer;
428-
rdata[cnt].data= (GinPageIsLeaf(page)) ? ((char*) (btree->items+btree->curitem)) : ((char*)&(btree->pitem));
429-
rdata[cnt].len=sizeofitem;
430-
rdata[cnt].next=NULL;
419+
rdata[2].buffer=InvalidBuffer;
420+
rdata[2].data= (GinPageIsLeaf(page)) ? ((char*) (btree->items+btree->curitem)) : ((char*)&(btree->pitem));
421+
rdata[2].len=sizeofitem;
422+
rdata[2].next=NULL;
431423

432424
if (GinPageIsLeaf(page))
433425
{
@@ -443,7 +435,7 @@ dataPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prda
443435
btree->curitem++;
444436
}
445437
data.nitem=btree->curitem-savedPos;
446-
rdata[cnt].len=sizeofitem*data.nitem;
438+
rdata[2].len=sizeofitem*data.nitem;
447439
}
448440
else
449441
{

‎src/backend/access/gin/ginentrypage.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
487487
{
488488
Pagepage=BufferGetPage(buf);
489489
OffsetNumberplaced;
490-
intcnt=0;
491490

492491
/* these must be static so they can be returned to caller */
493492
staticXLogRecDatardata[3];
@@ -510,32 +509,25 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
510509
data.isLeaf=GinPageIsLeaf(page) ? TRUE : FALSE;
511510

512511
/*
513-
* Prevent full page write if child's split occurs. That is needed to
514-
* remove incomplete splits while replaying WAL
515-
*
516-
* data.updateBlkno contains new block number (of newly created right
517-
* page) for recently splited page.
512+
* For incomplete-split tracking, we need updateBlkno information and the
513+
* inserted item even when we make a full page image of the page, so put
514+
* the buffer reference in a separate XLogRecData entry.
518515
*/
519-
if (data.updateBlkno==InvalidBlockNumber)
520-
{
521-
rdata[0].buffer=buf;
522-
rdata[0].buffer_std= TRUE;
523-
rdata[0].data=NULL;
524-
rdata[0].len=0;
525-
rdata[0].next=&rdata[1];
526-
cnt++;
527-
}
528-
529-
rdata[cnt].buffer=InvalidBuffer;
530-
rdata[cnt].data= (char*)&data;
531-
rdata[cnt].len=sizeof(ginxlogInsert);
532-
rdata[cnt].next=&rdata[cnt+1];
533-
cnt++;
516+
rdata[0].buffer=buf;
517+
rdata[0].buffer_std= TRUE;
518+
rdata[0].data=NULL;
519+
rdata[0].len=0;
520+
rdata[0].next=&rdata[1];
534521

535-
rdata[cnt].buffer=InvalidBuffer;
536-
rdata[cnt].data= (char*)btree->entry;
537-
rdata[cnt].len=IndexTupleSize(btree->entry);
538-
rdata[cnt].next=NULL;
522+
rdata[1].buffer=InvalidBuffer;
523+
rdata[1].data= (char*)&data;
524+
rdata[1].len=sizeof(ginxlogInsert);
525+
rdata[1].next=&rdata[2];
526+
527+
rdata[2].buffer=InvalidBuffer;
528+
rdata[2].data= (char*)btree->entry;
529+
rdata[2].len=IndexTupleSize(btree->entry);
530+
rdata[2].next=NULL;
539531

540532
btree->entry=NULL;
541533
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp