Commit 53502161 authored by Teodor Sigaev's avatar Teodor Sigaev

Improve error messages and add comment

parent 555f5139
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.6 2005/06/30 17:52:14 teodor Exp $ * $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.7 2005/07/01 13:18:17 teodor Exp $
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -162,7 +162,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) { ...@@ -162,7 +162,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) {
return; return;
buffer = XLogReadBuffer(false, reln, xlrec.data->blkno); buffer = XLogReadBuffer(false, reln, xlrec.data->blkno);
if (!BufferIsValid(buffer)) if (!BufferIsValid(buffer))
elog(PANIC, "gistRedoEntryUpdateRecord: block unfound"); elog(PANIC, "gistRedoEntryUpdateRecord: block %u unfound", xlrec.data->blkno);
page = (Page) BufferGetPage(buffer); page = (Page) BufferGetPage(buffer);
if ( isnewroot ) { if ( isnewroot ) {
...@@ -173,7 +173,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) { ...@@ -173,7 +173,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) {
} }
} else { } else {
if ( PageIsNew((PageHeader) page) ) if ( PageIsNew((PageHeader) page) )
elog(PANIC, "gistRedoEntryUpdateRecord: uninitialized page"); elog(PANIC, "gistRedoEntryUpdateRecord: uninitialized page blkno %u", xlrec.data->blkno);
if (XLByteLE(lsn, PageGetLSN(page))) { if (XLByteLE(lsn, PageGetLSN(page))) {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
...@@ -476,7 +476,7 @@ gistXLogReadAndLockBuffer( Relation r, BlockNumber blkno ) { ...@@ -476,7 +476,7 @@ gistXLogReadAndLockBuffer( Relation r, BlockNumber blkno ) {
if (!BufferIsValid(buffer)) if (!BufferIsValid(buffer))
elog(PANIC, "gistXLogReadAndLockBuffer: block %u unfound", blkno); elog(PANIC, "gistXLogReadAndLockBuffer: block %u unfound", blkno);
if ( PageIsNew( (PageHeader)(BufferGetPage(buffer)) ) ) if ( PageIsNew( (PageHeader)(BufferGetPage(buffer)) ) )
elog(PANIC, "gistXLogReadAndLockBuffer: uninitialized page %u", blkno); elog(PANIC, "gistXLogReadAndLockBuffer: uninitialized page blkno %u", blkno);
return buffer; return buffer;
} }
...@@ -510,6 +510,15 @@ gixtxlogFindPath( Relation index, gistIncompleteInsert *insert ) { ...@@ -510,6 +510,15 @@ gixtxlogFindPath( Relation index, gistIncompleteInsert *insert ) {
elog(LOG, "gixtxlogFindPath: lost parent for block %u", insert->origblkno); elog(LOG, "gixtxlogFindPath: lost parent for block %u", insert->origblkno);
} }
/*
* Continue insert after crash. In normal situation, there isn't any incomplete
* inserts, but if it might be after crash, WAL may has not a record of completetion.
*
* Although stored LSN in gistIncompleteInsert is a LSN of child page,
* we can compare it with LSN of parent, because parent is always locked
* while we change child page (look at gistmakedeal). So if parent's LSN is
* lesser than stored lsn then changes in parent doesn't do yet.
*/
static void static void
gistContinueInsert(gistIncompleteInsert *insert) { gistContinueInsert(gistIncompleteInsert *insert) {
IndexTuple *itup; IndexTuple *itup;
...@@ -574,7 +583,7 @@ gistContinueInsert(gistIncompleteInsert *insert) { ...@@ -574,7 +583,7 @@ gistContinueInsert(gistIncompleteInsert *insert) {
elog(PANIC, "gistContinueInsert: block %u unfound", insert->path[i]); elog(PANIC, "gistContinueInsert: block %u unfound", insert->path[i]);
pages[numbuffer-1] = BufferGetPage( buffers[numbuffer-1] ); pages[numbuffer-1] = BufferGetPage( buffers[numbuffer-1] );
if ( PageIsNew((PageHeader)(pages[numbuffer-1])) ) if ( PageIsNew((PageHeader)(pages[numbuffer-1])) )
elog(PANIC, "gistContinueInsert: uninitialized page"); elog(PANIC, "gistContinueInsert: uninitialized page blkno %u", insert->path[i]);
if (XLByteLE(insert->lsn, PageGetLSN(pages[numbuffer-1]))) { if (XLByteLE(insert->lsn, PageGetLSN(pages[numbuffer-1]))) {
LockBuffer(buffers[numbuffer-1], BUFFER_LOCK_UNLOCK); LockBuffer(buffers[numbuffer-1], BUFFER_LOCK_UNLOCK);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment