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

Commitcfa191f

Browse files
committed
Error message editing in backend/storage.
1 parent658fca8 commitcfa191f

File tree

25 files changed

+426
-321
lines changed

25 files changed

+426
-321
lines changed

‎src/backend/storage/buffer/buf_table.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.27 2002/06/20 20:29:34 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.28 2003/07/24 22:04:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -55,7 +55,7 @@ InitBufTable(void)
5555
HASH_ELEM |HASH_FUNCTION);
5656

5757
if (!SharedBufHash)
58-
elog(FATAL,"couldn'tinitialize shared bufferpool Hash Tbl");
58+
elog(FATAL,"could notinitialize shared bufferhash table");
5959
}
6060

6161
BufferDesc*
@@ -94,12 +94,8 @@ BufTableDelete(BufferDesc *buf)
9494
result= (BufferLookupEnt*)
9595
hash_search(SharedBufHash, (void*)&(buf->tag),HASH_REMOVE,NULL);
9696

97-
if (!result)
98-
{
99-
/* shouldn't happen */
100-
elog(ERROR,"BufTableDelete: BufferLookup table corrupted");
101-
return FALSE;
102-
}
97+
if (!result)/* shouldn't happen */
98+
elog(ERROR,"shared buffer hash table corrupted");
10399

104100
/*
105101
* Clear the buffer's tag. This doesn't matter for the hash table,
@@ -127,17 +123,12 @@ BufTableInsert(BufferDesc *buf)
127123
hash_search(SharedBufHash, (void*)&(buf->tag),HASH_ENTER,&found);
128124

129125
if (!result)
130-
{
131-
elog(ERROR,"BufTableInsert: BufferLookup table out of memory");
132-
return FALSE;
133-
}
134-
135-
/* found something else in the table ! */
136-
if (found)
137-
{
138-
elog(ERROR,"BufTableInsert: BufferLookup table corrupted");
139-
return FALSE;
140-
}
126+
ereport(ERROR,
127+
(errcode(ERRCODE_OUT_OF_MEMORY),
128+
errmsg("out of shared memory")));
129+
130+
if (found)/* found something else in the table? */
131+
elog(ERROR,"shared buffer hash table corrupted");
141132

142133
result->id=buf->buf_id;
143134
return TRUE;

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.136 2003/05/10 19:04:30 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.137 2003/07/24 22:04:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -229,13 +229,17 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
229229
{
230230
if (zero_damaged_pages)
231231
{
232-
elog(WARNING,"Invalid page header in block %u of %s; zeroing out page",
233-
blockNum,RelationGetRelationName(reln));
232+
ereport(WARNING,
233+
(errcode(ERRCODE_DATA_CORRUPTED),
234+
errmsg("invalid page header in block %u of \"%s\"; zeroing out page",
235+
blockNum,RelationGetRelationName(reln))));
234236
MemSet((char*)MAKE_PTR(bufHdr->data),0,BLCKSZ);
235237
}
236238
else
237-
elog(ERROR,"Invalid page header in block %u of %s",
238-
blockNum,RelationGetRelationName(reln));
239+
ereport(ERROR,
240+
(errcode(ERRCODE_DATA_CORRUPTED),
241+
errmsg("invalid page header in block %u of \"%s\"",
242+
blockNum,RelationGetRelationName(reln))));
239243
}
240244
}
241245

@@ -260,7 +264,7 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
260264
if (!BufTableDelete(bufHdr))
261265
{
262266
LWLockRelease(BufMgrLock);
263-
elog(FATAL,"BufRead:buffer table broken afterIO error");
267+
elog(FATAL,"buffer table broken afterI/O error");
264268
}
265269
/* remember that BufferAlloc() pinned the buffer */
266270
UnpinBuffer(bufHdr);
@@ -430,9 +434,12 @@ BufferAlloc(Relation reln,
430434

431435
if (smok== FALSE)
432436
{
433-
elog(WARNING,"BufferAlloc: cannot write block %u for %u/%u",
434-
buf->tag.blockNum,
435-
buf->tag.rnode.tblNode,buf->tag.rnode.relNode);
437+
ereport(WARNING,
438+
(errcode(ERRCODE_IO_ERROR),
439+
errmsg("could not write block %u of %u/%u",
440+
buf->tag.blockNum,
441+
buf->tag.rnode.tblNode,
442+
buf->tag.rnode.relNode)));
436443
inProgress= FALSE;
437444
buf->flags |=BM_IO_ERROR;
438445
buf->flags &= ~BM_IO_IN_PROGRESS;
@@ -448,7 +455,7 @@ BufferAlloc(Relation reln,
448455
*/
449456
if (buf->flags&BM_JUST_DIRTIED)
450457
{
451-
elog(PANIC,"BufferAlloc:content of block %u(%u/%u) changed while flushing",
458+
elog(PANIC,"content of block %uof%u/%u changed while flushing",
452459
buf->tag.blockNum,
453460
buf->tag.rnode.tblNode,buf->tag.rnode.relNode);
454461
}
@@ -540,15 +547,15 @@ BufferAlloc(Relation reln,
540547
if (!BufTableDelete(buf))
541548
{
542549
LWLockRelease(BufMgrLock);
543-
elog(FATAL,"buffer wasn't in the buffer table");
550+
elog(FATAL,"buffer wasn't in the bufferhashtable");
544551
}
545552

546553
INIT_BUFFERTAG(&(buf->tag),reln,blockNum);
547554

548555
if (!BufTableInsert(buf))
549556
{
550557
LWLockRelease(BufMgrLock);
551-
elog(FATAL,"Buffer inlookup table twice");
558+
elog(FATAL,"buffer inbuffer hash table twice");
552559
}
553560

554561
/*
@@ -587,7 +594,7 @@ write_buffer(Buffer buffer, bool release)
587594
}
588595

589596
if (BAD_BUFFER_ID(buffer))
590-
elog(ERROR,"write_buffer:bad buffer %d",buffer);
597+
elog(ERROR,"bad buffer id: %d",buffer);
591598

592599
bufHdr=&BufferDescriptors[buffer-1];
593600

@@ -809,9 +816,12 @@ BufferSync(void)
809816
}
810817

811818
if (status==SM_FAIL)/* disk failure ?! */
812-
elog(PANIC,"BufferSync: cannot write %u for %u/%u",
813-
bufHdr->tag.blockNum,
814-
bufHdr->tag.rnode.tblNode,bufHdr->tag.rnode.relNode);
819+
ereport(PANIC,
820+
(errcode(ERRCODE_IO_ERROR),
821+
errmsg("could not write block %u of %u/%u",
822+
bufHdr->tag.blockNum,
823+
bufHdr->tag.rnode.tblNode,
824+
bufHdr->tag.rnode.relNode)));
815825

816826
/*
817827
* Note that it's safe to change cntxDirty here because of we
@@ -932,7 +942,7 @@ ResetBufferUsage(void)
932942
*AtEOXact_Buffers - clean up at end of transaction.
933943
*
934944
*During abort, we need to release any buffer pins we're holding
935-
*(this cleans up in caseelog interrupted a routine that pins a
945+
*(this cleans up in caseereport interrupted a routine that pins a
936946
*buffer). During commit, we shouldn't need to do that, but check
937947
*anyway to see if anyone leaked a buffer reference count.
938948
*/
@@ -949,8 +959,8 @@ AtEOXact_Buffers(bool isCommit)
949959

950960
if (isCommit)
951961
elog(WARNING,
952-
"Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, "
953-
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)",
962+
"buffer refcount leak: [%03d] (freeNext=%d, freePrev=%d, "
963+
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)",
954964
i,buf->freeNext,buf->freePrev,
955965
buf->tag.rnode.tblNode,buf->tag.rnode.relNode,
956966
buf->tag.blockNum,buf->flags,
@@ -1206,8 +1216,10 @@ DropRelFileNodeBuffers(RelFileNode rnode, bool istemp)
12061216
{
12071217
/* the sole pin should be ours */
12081218
if (bufHdr->refcount!=1||PrivateRefCount[i-1]==0)
1209-
elog(FATAL,"DropRelFileNodeBuffers:block %uis referenced (private %ld, global %d)",
1219+
elog(FATAL,"block %uof %u/%u is still referenced (private %ld, global %d)",
12101220
bufHdr->tag.blockNum,
1221+
bufHdr->tag.rnode.tblNode,
1222+
bufHdr->tag.rnode.relNode,
12111223
PrivateRefCount[i-1],bufHdr->refcount);
12121224
/* Make sure it will be released */
12131225
PrivateRefCount[i-1]=1;
@@ -1427,7 +1439,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
14271439
if (status==SM_FAIL)
14281440
{
14291441
error_context_stack=errcontext.previous;
1430-
elog(WARNING,"FlushRelationBuffers(%s (local), %u): block %u is dirty, could not flush it",
1442+
elog(WARNING,"FlushRelationBuffers(\"%s\" (local), %u): block %u is dirty, could not flush it",
14311443
RelationGetRelationName(rel),firstDelBlock,
14321444
bufHdr->tag.blockNum);
14331445
return (-1);
@@ -1438,7 +1450,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
14381450
if (LocalRefCount[i]>0)
14391451
{
14401452
error_context_stack=errcontext.previous;
1441-
elog(WARNING,"FlushRelationBuffers(%s (local), %u): block %u is referenced (%ld)",
1453+
elog(WARNING,"FlushRelationBuffers(\"%s\" (local), %u): block %u is referenced (%ld)",
14421454
RelationGetRelationName(rel),firstDelBlock,
14431455
bufHdr->tag.blockNum,LocalRefCount[i]);
14441456
return (-2);
@@ -1495,10 +1507,12 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
14951507
(char*)MAKE_PTR(bufHdr->data));
14961508

14971509
if (status==SM_FAIL)/* disk failure ?! */
1498-
elog(PANIC,"FlushRelationBuffers: cannot write %u for %u/%u",
1499-
bufHdr->tag.blockNum,
1500-
bufHdr->tag.rnode.tblNode,
1501-
bufHdr->tag.rnode.relNode);
1510+
ereport(PANIC,
1511+
(errcode(ERRCODE_IO_ERROR),
1512+
errmsg("could not write block %u of %u/%u",
1513+
bufHdr->tag.blockNum,
1514+
bufHdr->tag.rnode.tblNode,
1515+
bufHdr->tag.rnode.relNode)));
15021516

15031517
BufferFlushCount++;
15041518

@@ -1522,7 +1536,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
15221536
{
15231537
LWLockRelease(BufMgrLock);
15241538
error_context_stack=errcontext.previous;
1525-
elog(WARNING,"FlushRelationBuffers(%s, %u): block %u is referenced (private %ld, global %d)",
1539+
elog(WARNING,"FlushRelationBuffers(\"%s\", %u): block %u is referenced (private %ld, global %d)",
15261540
RelationGetRelationName(rel),firstDelBlock,
15271541
bufHdr->tag.blockNum,
15281542
PrivateRefCount[i],bufHdr->refcount);
@@ -1825,7 +1839,7 @@ SetBufferCommitInfoNeedsSave(Buffer buffer)
18251839
}
18261840

18271841
if (BAD_BUFFER_ID(buffer))
1828-
elog(ERROR,"SetBufferCommitInfoNeedsSave:bad buffer %d",buffer);
1842+
elog(ERROR,"bad buffer id: %d",buffer);
18291843

18301844
bufHdr=&BufferDescriptors[buffer-1];
18311845

@@ -1919,7 +1933,7 @@ LockBuffer(Buffer buffer, int mode)
19191933
buf->cntxDirty= true;
19201934
}
19211935
else
1922-
elog(ERROR,"LockBuffer: unknown lock mode %d",mode);
1936+
elog(ERROR,"unrecognized buffer lock mode: %d",mode);
19231937
}
19241938

19251939
/*
@@ -1950,14 +1964,16 @@ LockBufferForCleanup(Buffer buffer)
19501964
{
19511965
/* There should be exactly one pin */
19521966
if (LocalRefCount[-buffer-1]!=1)
1953-
elog(ERROR,"LockBufferForCleanup: wrong local pin count");
1967+
elog(ERROR,"incorrect local pin count: %ld",
1968+
LocalRefCount[-buffer-1]);
19541969
/* Nobody else to wait for */
19551970
return;
19561971
}
19571972

19581973
/* There should be exactly one local pin */
19591974
if (PrivateRefCount[buffer-1]!=1)
1960-
elog(ERROR,"LockBufferForCleanup: wrong local pin count");
1975+
elog(ERROR,"incorrect local pin count: %ld",
1976+
PrivateRefCount[buffer-1]);
19611977

19621978
bufHdr=&BufferDescriptors[buffer-1];
19631979
buflock=&(BufferLocks[buffer-1]);
@@ -1979,7 +1995,7 @@ LockBufferForCleanup(Buffer buffer)
19791995
{
19801996
LWLockRelease(BufMgrLock);
19811997
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
1982-
elog(ERROR,"Multiple backends attempting to wait for pincount 1");
1998+
elog(ERROR,"multiple backends attempting to wait for pincount 1");
19831999
}
19842000
bufHdr->wait_backend_id=MyBackendId;
19852001
bufHdr->flags |=BM_PIN_COUNT_WAITER;
@@ -2102,9 +2118,13 @@ AbortBufferIO(void)
21022118
/* Issue notice if this is not the first failure... */
21032119
if (buf->flags&BM_IO_ERROR)
21042120
{
2105-
elog(WARNING,"write error may be permanent: cannot write block %u for %u/%u",
2106-
buf->tag.blockNum,
2107-
buf->tag.rnode.tblNode,buf->tag.rnode.relNode);
2121+
ereport(WARNING,
2122+
(errcode(ERRCODE_IO_ERROR),
2123+
errmsg("could not write block %u of %u/%u",
2124+
buf->tag.blockNum,
2125+
buf->tag.rnode.tblNode,
2126+
buf->tag.rnode.relNode),
2127+
errdetail("Multiple failures --- write error may be permanent.")));
21082128
}
21092129
buf->flags |=BM_DIRTY;
21102130
}

‎src/backend/storage/buffer/freelist.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.29 2002/06/20 20:29:34 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.30 2003/07/24 22:04:08 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -198,7 +198,9 @@ GetFreeBuffer(void)
198198
if (Free_List_Descriptor==SharedFreeList->freeNext)
199199
{
200200
/* queue is empty. All buffers in the buffer pool are pinned. */
201-
elog(ERROR,"out of free buffers: time to abort!");
201+
ereport(ERROR,
202+
(errcode(ERRCODE_INSUFFICIENT_RESOURCES),
203+
errmsg("out of free buffers")));
202204
returnNULL;
203205
}
204206
buf=&(BufferDescriptors[SharedFreeList->freeNext]);

‎src/backend/storage/buffer/localbuf.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.47 2002/12/05 22:48:03 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.48 2003/07/24 22:04:08 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -80,7 +80,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
8080
}
8181
}
8282
if (bufHdr==NULL)
83-
elog(ERROR,"no empty local buffer.");
83+
ereport(ERROR,
84+
(errcode(ERRCODE_INSUFFICIENT_RESOURCES),
85+
errmsg("no empty local buffer available")));
8486

8587
/*
8688
* this buffer is not referenced but it might still be dirty. if
@@ -122,7 +124,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
122124
char*data= (char*)malloc(BLCKSZ);
123125

124126
if (data==NULL)
125-
elog(ERROR,"Out of memory in LocalBufferAlloc");
127+
ereport(ERROR,
128+
(errcode(ERRCODE_OUT_OF_MEMORY),
129+
errmsg("out of memory")));
126130

127131
/*
128132
* This is a bit of a hack: bufHdr->data needs to be a shmem
@@ -229,7 +233,7 @@ AtEOXact_LocalBuffers(bool isCommit)
229233

230234
if (isCommit)
231235
elog(WARNING,
232-
"Local Buffer Leak: [%03d] (rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)",
236+
"local buffer leak: [%03d] (rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)",
233237
i,
234238
buf->tag.rnode.tblNode,buf->tag.rnode.relNode,
235239
buf->tag.blockNum,buf->flags,

‎src/backend/storage/file/buffile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.16 2003/04/29 03:21:29 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.17 2003/07/24 22:04:09 tgl Exp $
1111
*
1212
* NOTES:
1313
*
@@ -23,7 +23,7 @@
2323
* will go away automatically at transaction end. If the underlying
2424
* virtual File is made with OpenTemporaryFile, then all resources for
2525
* the file are certain to be cleaned up even if processing is aborted
26-
* byelog(ERROR).To avoid confusion, the caller should take care that
26+
* byereport(ERROR).To avoid confusion, the caller should take care that
2727
* all calls for a single BufFile are made in the same palloc context.
2828
*
2929
* BufFile also supports temporary files that exceed the OS file size limit
@@ -479,7 +479,7 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence)
479479
break;
480480
#endif
481481
default:
482-
elog(ERROR,"BufFileSeek:invalid whence: %d",whence);
482+
elog(ERROR,"invalid whence: %d",whence);
483483
returnEOF;
484484
}
485485
while (newOffset<0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp