Commit 7e8b0b9a authored by Heikki Linnakangas's avatar Heikki Linnakangas

Change error messages to print the physical path, like

"base/11517/3767_fsm", instead of symbolic names like "1663/11517/3767/1",
per Alvaro's suggestion. I didn't change the messages in the higher-level
index, heap and FSM routines, though, where the fork is implicit.
parent c7f5c7c1
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.266 2008/10/20 19:18:18 alvherre Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.267 2008/11/11 13:19:15 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -4338,12 +4338,10 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec) ...@@ -4338,12 +4338,10 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
appendStringInfo(buf, "; rels:"); appendStringInfo(buf, "; rels:");
for (i = 0; i < xlrec->nrels; i++) for (i = 0; i < xlrec->nrels; i++)
{ {
RelFileNode rnode = xlrec->xnodes[i].rnode; char *path = relpath(xlrec->xnodes[i].rnode,
ForkNumber forknum = xlrec->xnodes[i].forknum; xlrec->xnodes[i].forknum);
appendStringInfo(buf, " %s", path);
appendStringInfo(buf, " %u/%u/%u/%u", pfree(path);
rnode.spcNode, rnode.dbNode, rnode.relNode,
forknum);
} }
} }
if (xlrec->nsubxacts > 0) if (xlrec->nsubxacts > 0)
...@@ -4368,12 +4366,10 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec) ...@@ -4368,12 +4366,10 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
appendStringInfo(buf, "; rels:"); appendStringInfo(buf, "; rels:");
for (i = 0; i < xlrec->nrels; i++) for (i = 0; i < xlrec->nrels; i++)
{ {
RelFileNode rnode = xlrec->xnodes[i].rnode; char *path = relpath(xlrec->xnodes[i].rnode,
ForkNumber forknum = xlrec->xnodes[i].forknum; xlrec->xnodes[i].forknum);
appendStringInfo(buf, " %s", path);
appendStringInfo(buf, " %u/%u/%u/%u", pfree(path);
rnode.spcNode, rnode.dbNode, rnode.relNode,
forknum);
} }
} }
if (xlrec->nsubxacts > 0) if (xlrec->nsubxacts > 0)
......
...@@ -11,15 +11,17 @@ ...@@ -11,15 +11,17 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.61 2008/11/03 15:10:17 alvherre Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.62 2008/11/11 13:19:16 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
#include "access/xlogutils.h" #include "access/xlogutils.h"
#include "catalog/catalog.h"
#include "storage/bufmgr.h" #include "storage/bufmgr.h"
#include "storage/smgr.h" #include "storage/smgr.h"
#include "utils/guc.h"
#include "utils/hsearch.h" #include "utils/hsearch.h"
#include "utils/rel.h" #include "utils/rel.h"
...@@ -64,12 +66,17 @@ log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno, ...@@ -64,12 +66,17 @@ log_invalid_page(RelFileNode node, ForkNumber forkno, BlockNumber blkno,
* tracing of the cause (note the elog context mechanism will tell us * tracing of the cause (note the elog context mechanism will tell us
* something about the XLOG record that generated the reference). * something about the XLOG record that generated the reference).
*/ */
if (present) if (log_min_messages <= DEBUG1 || client_min_messages <= DEBUG1)
elog(DEBUG1, "page %u of relation %u/%u/%u/%u is uninitialized", {
blkno, node.spcNode, node.dbNode, node.relNode, forkno); char *path = relpath(node, forkno);
else if (present)
elog(DEBUG1, "page %u of relation %u/%u/%u/%u does not exist", elog(DEBUG1, "page %u of relation %s is uninitialized",
blkno, node.spcNode, node.dbNode, node.relNode, forkno); blkno, path);
else
elog(DEBUG1, "page %u of relation %s does not exist",
blkno, path);
pfree(path);
}
if (invalid_page_tab == NULL) if (invalid_page_tab == NULL)
{ {
...@@ -123,9 +130,13 @@ forget_invalid_pages(RelFileNode node, ForkNumber forkno, BlockNumber minblkno) ...@@ -123,9 +130,13 @@ forget_invalid_pages(RelFileNode node, ForkNumber forkno, BlockNumber minblkno)
hentry->key.forkno == forkno && hentry->key.forkno == forkno &&
hentry->key.blkno >= minblkno) hentry->key.blkno >= minblkno)
{ {
elog(DEBUG2, "page %u of relation %u/%u/%u/%u has been dropped", if (log_min_messages <= DEBUG2 || client_min_messages <= DEBUG2)
hentry->key.blkno, hentry->key.node.spcNode, {
hentry->key.node.dbNode, hentry->key.node.relNode, forkno); char *path = relpath(hentry->key.node, forkno);
elog(DEBUG2, "page %u of relation %s has been dropped",
hentry->key.blkno, path);
pfree(path);
}
if (hash_search(invalid_page_tab, if (hash_search(invalid_page_tab,
(void *) &hentry->key, (void *) &hentry->key,
...@@ -151,9 +162,13 @@ forget_invalid_pages_db(Oid dbid) ...@@ -151,9 +162,13 @@ forget_invalid_pages_db(Oid dbid)
{ {
if (hentry->key.node.dbNode == dbid) if (hentry->key.node.dbNode == dbid)
{ {
elog(DEBUG2, "page %u of relation %u/%u/%u has been dropped", if (log_min_messages <= DEBUG2 || client_min_messages <= DEBUG2)
hentry->key.blkno, hentry->key.node.spcNode, {
hentry->key.node.dbNode, hentry->key.node.relNode); char *path = relpath(hentry->key.node, hentry->key.forkno);
elog(DEBUG2, "page %u of relation %s has been dropped",
hentry->key.blkno, path);
pfree(path);
}
if (hash_search(invalid_page_tab, if (hash_search(invalid_page_tab,
(void *) &hentry->key, (void *) &hentry->key,
...@@ -182,14 +197,14 @@ XLogCheckInvalidPages(void) ...@@ -182,14 +197,14 @@ XLogCheckInvalidPages(void)
*/ */
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL) while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
{ {
char *path = relpath(hentry->key.node, hentry->key.forkno);
if (hentry->present) if (hentry->present)
elog(WARNING, "page %u of relation %u/%u/%u was uninitialized", elog(WARNING, "page %u of relation %s was uninitialized",
hentry->key.blkno, hentry->key.node.spcNode, hentry->key.blkno, path);
hentry->key.node.dbNode, hentry->key.node.relNode);
else else
elog(WARNING, "page %u of relation %u/%u/%u did not exist", elog(WARNING, "page %u of relation %s did not exist",
hentry->key.blkno, hentry->key.node.spcNode, hentry->key.blkno, path);
hentry->key.node.dbNode, hentry->key.node.relNode); pfree(path);
foundone = true; foundone = true;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.240 2008/10/31 15:05:00 heikki Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.241 2008/11/11 13:19:16 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <sys/file.h> #include <sys/file.h>
#include <unistd.h> #include <unistd.h>
#include "catalog/catalog.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "pg_trace.h" #include "pg_trace.h"
#include "pgstat.h" #include "pgstat.h"
...@@ -276,8 +277,8 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, ForkNumber forkNum, ...@@ -276,8 +277,8 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, ForkNumber forkNum,
bufBlock = isLocalBuf ? LocalBufHdrGetBlock(bufHdr) : BufHdrGetBlock(bufHdr); bufBlock = isLocalBuf ? LocalBufHdrGetBlock(bufHdr) : BufHdrGetBlock(bufHdr);
if (!PageIsNew((Page) bufBlock)) if (!PageIsNew((Page) bufBlock))
ereport(ERROR, ereport(ERROR,
(errmsg("unexpected data beyond EOF in block %u of relation %u/%u/%u/%u", (errmsg("unexpected data beyond EOF in block %u of relation %s",
blockNum, smgr->smgr_rnode.spcNode, smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode, forkNum), blockNum, relpath(smgr->smgr_rnode, forkNum)),
errhint("This has been seen to occur with buggy kernels; consider updating your system."))); errhint("This has been seen to occur with buggy kernels; consider updating your system.")));
/* /*
...@@ -350,21 +351,17 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, ForkNumber forkNum, ...@@ -350,21 +351,17 @@ ReadBuffer_common(SMgrRelation smgr, bool isLocalBuf, ForkNumber forkNum,
{ {
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("invalid page header in block %u of relation %u/%u/%u/%u; zeroing out page", errmsg("invalid page header in block %u of relation %s; zeroing out page",
blockNum, blockNum,
smgr->smgr_rnode.spcNode, relpath(smgr->smgr_rnode, forkNum))));
smgr->smgr_rnode.dbNode,
smgr->smgr_rnode.relNode,
forkNum)));
MemSet((char *) bufBlock, 0, BLCKSZ); MemSet((char *) bufBlock, 0, BLCKSZ);
} }
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("invalid page header in block %u of relation %u/%u/%u/%u", errmsg("invalid page header in block %u of relation %s",
blockNum, smgr->smgr_rnode.spcNode, blockNum,
smgr->smgr_rnode.dbNode, relpath(smgr->smgr_rnode, forkNum))));
smgr->smgr_rnode.relNode, forkNum)));
} }
} }
} }
...@@ -1645,6 +1642,7 @@ PrintBufferLeakWarning(Buffer buffer) ...@@ -1645,6 +1642,7 @@ PrintBufferLeakWarning(Buffer buffer)
{ {
volatile BufferDesc *buf; volatile BufferDesc *buf;
int32 loccount; int32 loccount;
char *path;
Assert(BufferIsValid(buffer)); Assert(BufferIsValid(buffer));
if (BufferIsLocal(buffer)) if (BufferIsLocal(buffer))
...@@ -1659,14 +1657,14 @@ PrintBufferLeakWarning(Buffer buffer) ...@@ -1659,14 +1657,14 @@ PrintBufferLeakWarning(Buffer buffer)
} }
/* theoretically we should lock the bufhdr here */ /* theoretically we should lock the bufhdr here */
path = relpath(buf->tag.rnode, buf->tag.forkNum);
elog(WARNING, elog(WARNING,
"buffer refcount leak: [%03d] " "buffer refcount leak: [%03d] "
"(rel=%u/%u/%u, forkNum=%u, blockNum=%u, flags=0x%x, refcount=%u %d)", "(rel=%s, blockNum=%u, flags=0x%x, refcount=%u %d)",
buffer, buffer, path,
buf->tag.rnode.spcNode, buf->tag.rnode.dbNode,
buf->tag.rnode.relNode, buf->tag.forkNum,
buf->tag.blockNum, buf->flags, buf->tag.blockNum, buf->flags,
buf->refcount, loccount); buf->refcount, loccount);
pfree(path);
} }
/* /*
...@@ -1973,11 +1971,10 @@ PrintBufferDescs(void) ...@@ -1973,11 +1971,10 @@ PrintBufferDescs(void)
{ {
/* theoretically we should lock the bufhdr here */ /* theoretically we should lock the bufhdr here */
elog(LOG, elog(LOG,
"[%02d] (freeNext=%d, rel=%u/%u/%u, forkNum=%u, " "[%02d] (freeNext=%d, rel=%s, "
"blockNum=%u, flags=0x%x, refcount=%u %d)", "blockNum=%u, flags=0x%x, refcount=%u %d)",
i, buf->freeNext, i, buf->freeNext,
buf->tag.rnode.spcNode, buf->tag.rnode.dbNode, relpath(buf->tag.rnode, buf->tag.forkNum),
buf->tag.rnode.relNode, buf->tag.forkNum,
buf->tag.blockNum, buf->flags, buf->tag.blockNum, buf->flags,
buf->refcount, PrivateRefCount[i]); buf->refcount, PrivateRefCount[i]);
} }
...@@ -1997,11 +1994,10 @@ PrintPinnedBufs(void) ...@@ -1997,11 +1994,10 @@ PrintPinnedBufs(void)
{ {
/* theoretically we should lock the bufhdr here */ /* theoretically we should lock the bufhdr here */
elog(LOG, elog(LOG,
"[%02d] (freeNext=%d, rel=%u/%u/%u, forkNum=%u, " "[%02d] (freeNext=%d, rel=%s, "
"blockNum=%u, flags=0x%x, refcount=%u %d)", "blockNum=%u, flags=0x%x, refcount=%u %d)",
i, buf->freeNext, i, buf->freeNext,
buf->tag.rnode.spcNode, buf->tag.rnode.dbNode, relpath(buf->tag.rnode, buf->tag.forkNum),
buf->tag.rnode.relNode, buf->tag.forkNum,
buf->tag.blockNum, buf->flags, buf->tag.blockNum, buf->flags,
buf->refcount, PrivateRefCount[i]); buf->refcount, PrivateRefCount[i]);
} }
...@@ -2634,14 +2630,13 @@ AbortBufferIO(void) ...@@ -2634,14 +2630,13 @@ AbortBufferIO(void)
if (sv_flags & BM_IO_ERROR) if (sv_flags & BM_IO_ERROR)
{ {
/* Buffer is pinned, so we can read tag without spinlock */ /* Buffer is pinned, so we can read tag without spinlock */
char *path = relpath(buf->tag.rnode, buf->tag.forkNum);
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_IO_ERROR), (errcode(ERRCODE_IO_ERROR),
errmsg("could not write block %u of %u/%u/%u/%u", errmsg("could not write block %u of %s",
buf->tag.blockNum, buf->tag.blockNum, path),
buf->tag.rnode.spcNode,
buf->tag.rnode.dbNode,
buf->tag.rnode.relNode, buf->tag.forkNum),
errdetail("Multiple failures --- write error might be permanent."))); errdetail("Multiple failures --- write error might be permanent.")));
pfree(path);
} }
} }
TerminateBufferIO(buf, false, BM_IO_ERROR); TerminateBufferIO(buf, false, BM_IO_ERROR);
...@@ -2658,10 +2653,10 @@ buffer_write_error_callback(void *arg) ...@@ -2658,10 +2653,10 @@ buffer_write_error_callback(void *arg)
/* Buffer is pinned, so we can read the tag without locking the spinlock */ /* Buffer is pinned, so we can read the tag without locking the spinlock */
if (bufHdr != NULL) if (bufHdr != NULL)
errcontext("writing block %u of relation %u/%u/%u/%u", {
bufHdr->tag.blockNum, char *path = relpath(bufHdr->tag.rnode, bufHdr->tag.forkNum);
bufHdr->tag.rnode.spcNode, errcontext("writing block %u of relation %s",
bufHdr->tag.rnode.dbNode, bufHdr->tag.blockNum, path);
bufHdr->tag.rnode.relNode, pfree(path);
bufHdr->tag.forkNum); }
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.81 2008/08/11 11:05:11 heikki Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.82 2008/11/11 13:19:16 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -268,11 +268,9 @@ DropRelFileNodeLocalBuffers(RelFileNode rnode, ForkNumber forkNum, ...@@ -268,11 +268,9 @@ DropRelFileNodeLocalBuffers(RelFileNode rnode, ForkNumber forkNum,
bufHdr->tag.blockNum >= firstDelBlock) bufHdr->tag.blockNum >= firstDelBlock)
{ {
if (LocalRefCount[i] != 0) if (LocalRefCount[i] != 0)
elog(ERROR, "block %u of %u/%u/%u is still referenced (local %u)", elog(ERROR, "block %u of %s is still referenced (local %u)",
bufHdr->tag.blockNum, bufHdr->tag.blockNum,
bufHdr->tag.rnode.spcNode, relpath(bufHdr->tag.rnode, bufHdr->tag.forkNum),
bufHdr->tag.rnode.dbNode,
bufHdr->tag.rnode.relNode,
LocalRefCount[i]); LocalRefCount[i]);
/* Remove entry from hashtable */ /* Remove entry from hashtable */
hresult = (LocalBufferLookupEnt *) hresult = (LocalBufferLookupEnt *)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.139 2008/08/11 11:05:11 heikki Exp $ * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.140 2008/11/11 13:19:16 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -258,11 +258,7 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo) ...@@ -258,11 +258,7 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
errno = save_errno; errno = save_errno;
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not create relation %u/%u/%u/%u: %m", errmsg("could not create relation %s: %m", path)));
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forkNum)));
} }
} }
...@@ -349,11 +345,7 @@ mdunlink(RelFileNode rnode, ForkNumber forkNum, bool isRedo) ...@@ -349,11 +345,7 @@ mdunlink(RelFileNode rnode, ForkNumber forkNum, bool isRedo)
if (!isRedo || errno != ENOENT) if (!isRedo || errno != ENOENT)
ereport(WARNING, ereport(WARNING,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not remove relation %u/%u/%u/%u: %m", errmsg("could not remove relation %s: %m", path)));
rnode.spcNode,
rnode.dbNode,
rnode.relNode,
forkNum)));
} }
/* /*
...@@ -377,12 +369,8 @@ mdunlink(RelFileNode rnode, ForkNumber forkNum, bool isRedo) ...@@ -377,12 +369,8 @@ mdunlink(RelFileNode rnode, ForkNumber forkNum, bool isRedo)
if (errno != ENOENT) if (errno != ENOENT)
ereport(WARNING, ereport(WARNING,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not remove segment %u of relation %u/%u/%u/%u: %m", errmsg("could not remove segment %u of relation %s: %m",
segno, segno, path)));
rnode.spcNode,
rnode.dbNode,
rnode.relNode,
forkNum)));
break; break;
} }
} }
...@@ -426,11 +414,8 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, ...@@ -426,11 +414,8 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
if (blocknum == InvalidBlockNumber) if (blocknum == InvalidBlockNumber)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("cannot extend relation %u/%u/%u/%u beyond %u blocks", errmsg("cannot extend relation %s beyond %u blocks",
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
InvalidBlockNumber))); InvalidBlockNumber)));
v = _mdfd_getseg(reln, forknum, blocknum, isTemp, EXTENSION_CREATE); v = _mdfd_getseg(reln, forknum, blocknum, isTemp, EXTENSION_CREATE);
...@@ -450,32 +435,23 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, ...@@ -450,32 +435,23 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos) if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not seek to block %u of relation %u/%u/%u/%u: %m", errmsg("could not seek to block %u of relation %s: %m",
blocknum, blocknum,
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ) if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{ {
if (nbytes < 0) if (nbytes < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not extend relation %u/%u/%u/%u: %m", errmsg("could not extend relation %s: %m",
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum)),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum),
errhint("Check free disk space."))); errhint("Check free disk space.")));
/* short write: complain appropriately */ /* short write: complain appropriately */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DISK_FULL), (errcode(ERRCODE_DISK_FULL),
errmsg("could not extend relation %u/%u/%u/%u: wrote only %d of %d bytes at block %u", errmsg("could not extend relation %s: wrote only %d of %d bytes at block %u",
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
nbytes, BLCKSZ, blocknum), nbytes, BLCKSZ, blocknum),
errhint("Check free disk space."))); errhint("Check free disk space.")));
} }
...@@ -529,11 +505,7 @@ mdopen(SMgrRelation reln, ForkNumber forknum, ExtensionBehavior behavior) ...@@ -529,11 +505,7 @@ mdopen(SMgrRelation reln, ForkNumber forknum, ExtensionBehavior behavior)
return NULL; return NULL;
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not open relation %u/%u/%u/%u: %m", errmsg("could not open relation %s: %m", path)));
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
} }
} }
...@@ -595,24 +567,16 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, ...@@ -595,24 +567,16 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos) if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not seek to block %u of relation %u/%u/%u/%u: %m", errmsg("could not seek to block %u of relation %s: %m",
blocknum, blocknum, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ) if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{ {
if (nbytes < 0) if (nbytes < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not read block %u of relation %u/%u/%u/%u: %m", errmsg("could not read block %u of relation %s: %m",
blocknum, blocknum, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
/* /*
* Short read: we are at or past EOF, or we read a partial block at * Short read: we are at or past EOF, or we read a partial block at
...@@ -627,12 +591,8 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, ...@@ -627,12 +591,8 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("could not read block %u of relation %u/%u/%u/%u: read only %d of %d bytes", errmsg("could not read block %u of relation %s: read only %d of %d bytes",
blocknum, blocknum, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
nbytes, BLCKSZ))); nbytes, BLCKSZ)));
} }
} }
...@@ -665,33 +625,22 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, ...@@ -665,33 +625,22 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos) if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not seek to block %u of relation %u/%u/%u/%u: %m", errmsg("could not seek to block %u of relation %s: %m",
blocknum, blocknum, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ) if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{ {
if (nbytes < 0) if (nbytes < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not write block %u of relation %u/%u/%u/%u: %m", errmsg("could not write block %u of relation %s: %m",
blocknum, blocknum, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
/* short write: complain appropriately */ /* short write: complain appropriately */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DISK_FULL), (errcode(ERRCODE_DISK_FULL),
errmsg("could not write block %u of relation %u/%u/%u/%u: wrote only %d of %d bytes", errmsg("could not write block %u of relation %s: wrote only %d of %d bytes",
blocknum, blocknum,
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
nbytes, BLCKSZ), nbytes, BLCKSZ),
errhint("Check free disk space."))); errhint("Check free disk space.")));
} }
...@@ -758,12 +707,9 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum) ...@@ -758,12 +707,9 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum)
if (v->mdfd_chain == NULL) if (v->mdfd_chain == NULL)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not open segment %u of relation %u/%u/%u/%u: %m", errmsg("could not open segment %u of relation %s: %m",
segno, segno,
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
} }
v = v->mdfd_chain; v = v->mdfd_chain;
...@@ -792,11 +738,8 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks, ...@@ -792,11 +738,8 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks,
if (InRecovery) if (InRecovery)
return; return;
ereport(ERROR, ereport(ERROR,
(errmsg("could not truncate relation %u/%u/%u/%u to %u blocks: it's only %u blocks now", (errmsg("could not truncate relation %s to %u blocks: it's only %u blocks now",
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
nblocks, curnblk))); nblocks, curnblk)));
} }
if (nblocks == curnblk) if (nblocks == curnblk)
...@@ -819,11 +762,8 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks, ...@@ -819,11 +762,8 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks,
if (FileTruncate(v->mdfd_vfd, 0) < 0) if (FileTruncate(v->mdfd_vfd, 0) < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not truncate relation %u/%u/%u/%u to %u blocks: %m", errmsg("could not truncate relation %s to %u blocks: %m",
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
nblocks))); nblocks)));
if (!isTemp) if (!isTemp)
register_dirty_segment(reln, forknum, v); register_dirty_segment(reln, forknum, v);
...@@ -846,11 +786,8 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks, ...@@ -846,11 +786,8 @@ mdtruncate(SMgrRelation reln, ForkNumber forknum, BlockNumber nblocks,
if (FileTruncate(v->mdfd_vfd, (off_t) lastsegblocks * BLCKSZ) < 0) if (FileTruncate(v->mdfd_vfd, (off_t) lastsegblocks * BLCKSZ) < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not truncate relation %u/%u/%u/%u to %u blocks: %m", errmsg("could not truncate relation %s to %u blocks: %m",
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
nblocks))); nblocks)));
if (!isTemp) if (!isTemp)
register_dirty_segment(reln, forknum, v); register_dirty_segment(reln, forknum, v);
...@@ -894,12 +831,9 @@ mdimmedsync(SMgrRelation reln, ForkNumber forknum) ...@@ -894,12 +831,9 @@ mdimmedsync(SMgrRelation reln, ForkNumber forknum)
if (FileSync(v->mdfd_vfd) < 0) if (FileSync(v->mdfd_vfd) < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not fsync segment %u of relation %u/%u/%u/%u: %m", errmsg("could not fsync segment %u of relation %s: %m",
v->mdfd_segno, v->mdfd_segno,
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
v = v->mdfd_chain; v = v->mdfd_chain;
} }
} }
...@@ -1027,6 +961,7 @@ mdsync(void) ...@@ -1027,6 +961,7 @@ mdsync(void)
{ {
SMgrRelation reln; SMgrRelation reln;
MdfdVec *seg; MdfdVec *seg;
char *path;
/* /*
* Find or create an smgr hash entry for this relation. This * Find or create an smgr hash entry for this relation. This
...@@ -1065,25 +1000,19 @@ mdsync(void) ...@@ -1065,25 +1000,19 @@ mdsync(void)
* Don't see one at the moment, but easy to change the test * Don't see one at the moment, but easy to change the test
* here if so. * here if so.
*/ */
path = relpath(entry->tag.rnode, entry->tag.forknum);
if (!FILE_POSSIBLY_DELETED(errno) || if (!FILE_POSSIBLY_DELETED(errno) ||
failures > 0) failures > 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not fsync segment %u of relation %u/%u/%u/%u: %m", errmsg("could not fsync segment %u of relation %s: %m",
entry->tag.segno, entry->tag.segno, path)));
entry->tag.rnode.spcNode,
entry->tag.rnode.dbNode,
entry->tag.rnode.relNode,
entry->tag.forknum)));
else else
ereport(DEBUG1, ereport(DEBUG1,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not fsync segment %u of relation %u/%u/%u/%u but retrying: %m", errmsg("could not fsync segment %u of relation %s but retrying: %m",
entry->tag.segno, entry->tag.segno, path)));
entry->tag.rnode.spcNode, pfree(path);
entry->tag.rnode.dbNode,
entry->tag.rnode.relNode,
entry->tag.forknum)));
/* /*
* Absorb incoming requests and check to see if canceled. * Absorb incoming requests and check to see if canceled.
...@@ -1186,11 +1115,7 @@ mdpostckpt(void) ...@@ -1186,11 +1115,7 @@ mdpostckpt(void)
if (errno != ENOENT) if (errno != ENOENT)
ereport(WARNING, ereport(WARNING,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not remove relation %u/%u/%u/%u: %m", errmsg("could not remove relation %s: %m", path)));
entry->rnode.spcNode,
entry->rnode.dbNode,
entry->rnode.relNode,
MAIN_FORKNUM)));
} }
pfree(path); pfree(path);
...@@ -1224,12 +1149,9 @@ register_dirty_segment(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg) ...@@ -1224,12 +1149,9 @@ register_dirty_segment(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
if (FileSync(seg->mdfd_vfd) < 0) if (FileSync(seg->mdfd_vfd) < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not fsync segment %u of relation %u/%u/%u/%u: %m", errmsg("could not fsync segment %u of relation %s: %m",
seg->mdfd_segno, seg->mdfd_segno,
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
} }
} }
...@@ -1574,12 +1496,9 @@ _mdfd_getseg(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno, ...@@ -1574,12 +1496,9 @@ _mdfd_getseg(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno,
return NULL; return NULL;
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not open segment %u of relation %u/%u/%u/%u (target block %u): %m", errmsg("could not open segment %u of relation %s (target block %u): %m",
nextsegno, nextsegno,
reln->smgr_rnode.spcNode, relpath(reln->smgr_rnode, forknum),
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum,
blkno))); blkno)));
} }
} }
...@@ -1600,12 +1519,8 @@ _mdnblocks(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg) ...@@ -1600,12 +1519,8 @@ _mdnblocks(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
if (len < 0) if (len < 0)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not seek to end of segment %u of relation %u/%u/%u/%u: %m", errmsg("could not seek to end of segment %u of relation %s: %m",
seg->mdfd_segno, seg->mdfd_segno, relpath(reln->smgr_rnode, forknum))));
reln->smgr_rnode.spcNode,
reln->smgr_rnode.dbNode,
reln->smgr_rnode.relNode,
forknum)));
/* note that this calculation will ignore any partial block at EOF */ /* note that this calculation will ignore any partial block at EOF */
return (BlockNumber) (len / BLCKSZ); return (BlockNumber) (len / BLCKSZ);
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.112 2008/09/30 10:52:13 heikki Exp $ * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.113 2008/11/11 13:19:16 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "access/xact.h" #include "access/xact.h"
#include "access/xlogutils.h" #include "access/xlogutils.h"
#include "catalog/catalog.h"
#include "commands/tablespace.h" #include "commands/tablespace.h"
#include "storage/bufmgr.h" #include "storage/bufmgr.h"
#include "storage/ipc.h" #include "storage/ipc.h"
...@@ -911,19 +912,19 @@ smgr_desc(StringInfo buf, uint8 xl_info, char *rec) ...@@ -911,19 +912,19 @@ smgr_desc(StringInfo buf, uint8 xl_info, char *rec)
if (info == XLOG_SMGR_CREATE) if (info == XLOG_SMGR_CREATE)
{ {
xl_smgr_create *xlrec = (xl_smgr_create *) rec; xl_smgr_create *xlrec = (xl_smgr_create *) rec;
char *path = relpath(xlrec->rnode, xlrec->forknum);
appendStringInfo(buf, "file create: %u/%u/%u/%u", appendStringInfo(buf, "file create: %s", path);
xlrec->rnode.spcNode, xlrec->rnode.dbNode, pfree(path);
xlrec->rnode.relNode, xlrec->forknum);
} }
else if (info == XLOG_SMGR_TRUNCATE) else if (info == XLOG_SMGR_TRUNCATE)
{ {
xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec; xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
char *path = relpath(xlrec->rnode, xlrec->forknum);
appendStringInfo(buf, "file truncate: %u/%u/%u/%u to %u blocks", appendStringInfo(buf, "file truncate: %s to %u blocks", path,
xlrec->rnode.spcNode, xlrec->rnode.dbNode,
xlrec->rnode.relNode, xlrec->forknum,
xlrec->blkno); xlrec->blkno);
pfree(path);
} }
else else
appendStringInfo(buf, "UNKNOWN"); appendStringInfo(buf, "UNKNOWN");
......
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