display offset along with block number in vacuum errors

From: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: display offset along with block number in vacuum errors
Date: 2020-07-24 17:48:43
Message-ID: CAKYtNApK488TDF4bMbw+1QH8HJf9cxdNDXquhU50TK5iv_FtCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,
We discussed in another email thread[1], that it will be helpful if we can
display offset along with block number in vacuum error. Here, proposing a
patch to add offset along with block number in vacuum errors.

In commit b61d161(Introduce vacuum errcontext to display additional
information), we added vacuum errcontext to display additional
information(block number) so that in case of vacuum error, we can identify
which block we are getting error. Addition to block number, if we can
display offset, then it will be more helpful for users. So to display
offset, here proposing two different methods(Thanks Robert for suggesting
these 2 methods):

*Method 1:* We can report the TID as well as the block number in
errcontext.
- errcontext("while scanning block %u of relation \"%s.%s\"",
- errinfo->blkno, errinfo->relnamespace, errinfo->relname);
+ errcontext("while scanning block %u and offset %u of relation \"%s.%s\"",
+ errinfo->blkno, errinfo->offnum, errinfo->relnamespace,
errinfo->relname);

Above fix requires more calls to update_vacuum_error_info(). Attaching
v01_0001 patch for this method.

*Method 2: *We can improve the error messages by passing the relevant TID
to heap_prepare_freeze_tuple and having it report the TID as part of the
error message or in the error detail.
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found xmin %u from before relfrozenxid %u",
+ errmsg_internal("for block %u and offnum %u, found xmin %u from before
relfrozenxid %u",
+ ItemPointerGetBlockNumber(tid),
+ ItemPointerGetOffsetNumber(tid),
xid, relfrozenxid)));

Attaching v01_0002 patch for this method.

Please let me know your thoughts.

[1] : http://postgr.es/m/20200713223822.az6fo3m2x4t42xz2@alap3.anarazel.de
--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
v01_0001-Added-offset-with-block-number-in-vacuum-errcontext.patch application/octet-stream 7.0 KB
v01_0002-Added-block-and-offset-to-errors-of-heap_prepare_fre.patch application/octet-stream 7.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-07-24 18:01:53 Re: Missing CFI in hlCover()?
Previous Message Tom Lane 2020-07-24 17:46:03 Re: Making CASE error handling less surprising