Skip to content

Commit 5350216

Browse files
committed
Improve error messages and add comment
1 parent 555f513 commit 5350216

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/backend/access/gist/gistxlog.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.6 2005/06/30 17:52:14 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.7 2005/07/01 13:18:17 teodor Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
@@ -162,7 +162,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) {
162162
return;
163163
buffer = XLogReadBuffer(false, reln, xlrec.data->blkno);
164164
if (!BufferIsValid(buffer))
165-
elog(PANIC, "gistRedoEntryUpdateRecord: block unfound");
165+
elog(PANIC, "gistRedoEntryUpdateRecord: block %u unfound", xlrec.data->blkno);
166166
page = (Page) BufferGetPage(buffer);
167167

168168
if ( isnewroot ) {
@@ -173,7 +173,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) {
173173
}
174174
} else {
175175
if ( PageIsNew((PageHeader) page) )
176-
elog(PANIC, "gistRedoEntryUpdateRecord: uninitialized page");
176+
elog(PANIC, "gistRedoEntryUpdateRecord: uninitialized page blkno %u", xlrec.data->blkno);
177177
if (XLByteLE(lsn, PageGetLSN(page))) {
178178
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
179179
ReleaseBuffer(buffer);
@@ -476,7 +476,7 @@ gistXLogReadAndLockBuffer( Relation r, BlockNumber blkno ) {
476476
if (!BufferIsValid(buffer))
477477
elog(PANIC, "gistXLogReadAndLockBuffer: block %u unfound", blkno);
478478
if ( PageIsNew( (PageHeader)(BufferGetPage(buffer)) ) )
479-
elog(PANIC, "gistXLogReadAndLockBuffer: uninitialized page %u", blkno);
479+
elog(PANIC, "gistXLogReadAndLockBuffer: uninitialized page blkno %u", blkno);
480480

481481
return buffer;
482482
}
@@ -510,6 +510,15 @@ gixtxlogFindPath( Relation index, gistIncompleteInsert *insert ) {
510510
elog(LOG, "gixtxlogFindPath: lost parent for block %u", insert->origblkno);
511511
}
512512

513+
/*
514+
* Continue insert after crash. In normal situation, there isn't any incomplete
515+
* inserts, but if it might be after crash, WAL may has not a record of completetion.
516+
*
517+
* Although stored LSN in gistIncompleteInsert is a LSN of child page,
518+
* we can compare it with LSN of parent, because parent is always locked
519+
* while we change child page (look at gistmakedeal). So if parent's LSN is
520+
* lesser than stored lsn then changes in parent doesn't do yet.
521+
*/
513522
static void
514523
gistContinueInsert(gistIncompleteInsert *insert) {
515524
IndexTuple *itup;
@@ -574,7 +583,7 @@ gistContinueInsert(gistIncompleteInsert *insert) {
574583
elog(PANIC, "gistContinueInsert: block %u unfound", insert->path[i]);
575584
pages[numbuffer-1] = BufferGetPage( buffers[numbuffer-1] );
576585
if ( PageIsNew((PageHeader)(pages[numbuffer-1])) )
577-
elog(PANIC, "gistContinueInsert: uninitialized page");
586+
elog(PANIC, "gistContinueInsert: uninitialized page blkno %u", insert->path[i]);
578587

579588
if (XLByteLE(insert->lsn, PageGetLSN(pages[numbuffer-1]))) {
580589
LockBuffer(buffers[numbuffer-1], BUFFER_LOCK_UNLOCK);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy