mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Add error codes to some corruption log messages
In some cases we have elog(ERROR) while corruption is certain and we can give a clear error code ERRCODE_DATA_CORRUPTED or ERRCODE_INDEX_CORRUPTED. Author: Andrey Borodin <x4mmm@yandex-team.ru> Discussion: https://www.postgresql.org/message-id/flat/25F6C686-6442-4A6B-BAF8-A6F7B84B16DE@yandex-team.ru
This commit is contained in:
@@ -423,7 +423,9 @@ tuple_lock_retry:
|
||||
|
||||
/* otherwise xmin should not be dirty... */
|
||||
if (TransactionIdIsValid(SnapshotDirty.xmin))
|
||||
elog(ERROR, "t_xmin is uncommitted in tuple to be updated");
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg_internal("t_xmin is uncommitted in tuple to be updated")));
|
||||
|
||||
/*
|
||||
* If tuple is being updated by other transaction then we
|
||||
|
@@ -1966,35 +1966,43 @@ toast_fetch_datum(struct varlena *attr)
|
||||
* Some checks on the data we've found
|
||||
*/
|
||||
if (residx != nextidx)
|
||||
elog(ERROR, "unexpected chunk number %d (expected %d) for toast value %u in %s",
|
||||
residx, nextidx,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg_internal("unexpected chunk number %d (expected %d) for toast value %u in %s",
|
||||
residx, nextidx,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel))));
|
||||
if (residx < numchunks - 1)
|
||||
{
|
||||
if (chunksize != TOAST_MAX_CHUNK_SIZE)
|
||||
elog(ERROR, "unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u in %s",
|
||||
chunksize, (int) TOAST_MAX_CHUNK_SIZE,
|
||||
residx, numchunks,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg_internal("unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u in %s",
|
||||
chunksize, (int) TOAST_MAX_CHUNK_SIZE,
|
||||
residx, numchunks,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel))));
|
||||
}
|
||||
else if (residx == numchunks - 1)
|
||||
{
|
||||
if ((residx * TOAST_MAX_CHUNK_SIZE + chunksize) != ressize)
|
||||
elog(ERROR, "unexpected chunk size %d (expected %d) in final chunk %d for toast value %u in %s",
|
||||
chunksize,
|
||||
(int) (ressize - residx * TOAST_MAX_CHUNK_SIZE),
|
||||
residx,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg_internal("unexpected chunk size %d (expected %d) in final chunk %d for toast value %u in %s",
|
||||
chunksize,
|
||||
(int) (ressize - residx * TOAST_MAX_CHUNK_SIZE),
|
||||
residx,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel))));
|
||||
}
|
||||
else
|
||||
elog(ERROR, "unexpected chunk number %d (out of range %d..%d) for toast value %u in %s",
|
||||
residx,
|
||||
0, numchunks - 1,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg_internal("unexpected chunk number %d (out of range %d..%d) for toast value %u in %s",
|
||||
residx,
|
||||
0, numchunks - 1,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel))));
|
||||
|
||||
/*
|
||||
* Copy the data into proper place in our result
|
||||
@@ -2010,10 +2018,12 @@ toast_fetch_datum(struct varlena *attr)
|
||||
* Final checks that we successfully fetched the datum
|
||||
*/
|
||||
if (nextidx != numchunks)
|
||||
elog(ERROR, "missing chunk number %d for toast value %u in %s",
|
||||
nextidx,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel));
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg_internal("missing chunk number %d for toast value %u in %s",
|
||||
nextidx,
|
||||
toast_pointer.va_valueid,
|
||||
RelationGetRelationName(toastrel))));
|
||||
|
||||
/*
|
||||
* End scan and close relations
|
||||
|
Reference in New Issue
Block a user