Re: Assertion failure in smgr.c when using pg_prewarm with partitioned tables

From: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Richard Guo <guofenglinux(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Assertion failure in smgr.c when using pg_prewarm with partitioned tables
Date: 2025-05-29 02:46:41
Message-ID: dfe167ebf508b9693a7f870b261df22a@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for your feedback. I've attached the updated patches.

On 2025-05-28 10:10, Fujii Masao wrote:
> On 2025/05/26 16:55, ikedamsh wrote:
>> 2025/05/21 12:54 Fujii Masao <masao(dot)fujii(at)gmail(dot)com>:
>> Regarding the 0002 patch:
>>
>> - errdetail("Relation \"%s\" is a %s index.",
>> - RelationGetRelationName(rel), NameStr(((Form_pg_am)
>> GETSTRUCT(amtuprel))->amname))));
>> + errdetail("Relation \"%s\" is a %s %sindex.",
>> + RelationGetRelationName(rel), NameStr(((Form_pg_am)
>> GETSTRUCT(amtuprel))->amname),
>> + (rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX) ?
>> "partitioned " : "")));
>>
>> Instead of manually building the message, how about using
>> errdetail_relkind_not_supported()?
>> It would be more consistent with similar error reporting
>> elsewhere.
>>
>> I was thinking of using errdetail_relkind_not_supported(),
>> but I’m reconsidering building the message manually
>> since the AM name seems to be important for the error.
>> What do you think?
>
> Understood.
> I was trying to better understand the error message, as I found
> the following is still a bit confusing for users. However, I don't
> have a better suggestion at the moment, so I'm okay with
> the proposed change.
>
> ERROR: expected "btree" index as targets for verification
> DETAIL: Relation "pgbench_accounts_pkey" is a btree partitioned

What do you think about adding new error messages specifically for
partitioned
indexes?

If the target is a partitioned index, the error messages would be:

ERROR: expected index as targets for verification
DETAIL: This operation is not supported for partitioned indexes.

If the target is an index, but its access method is not supported, the
error
messages would be:

ERROR: expected "btree" index as targets for verification
DETAIL: Relation "bttest_a_brin_idx" is a brin index.

> This is not directly relation to your proposal, but while reading
> the index_checkable() function, I noticed that ReleaseSysCache()
> is not called after SearchSysCache1(). Shouldn't we call
> ReleaseSysCache() here? Alternatively, we could use get_am_name()
> instead of SearchSysCache1(), which might be simpler.

Agreed.

> I also observed that the error code ERRCODE_FEATURE_NOT_SUPPORTED
> is used when the relation is not the expected type in
> index_checkable().
> However, based on similar cases (e.g., pgstattuple), it seems that
> ERRCODE_WRONG_OBJECT_TYPE might be more appropriate in this situation.
> Thought?

Agreed. I also change the error code to
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
when the index is not valid.

Regards,
--
Masahiro Ikeda
NTT DATA Japan Corporation

Attachment Content-Type Size
v4-0001-Fix-assertion-failure-when-pg_prewarm-is-run-on-o.patch text/x-diff 3.7 KB
v4-0002-Fix-error-message-for-partitioned-indexes-in-amch.patch text/x-diff 3.3 KB
v4-0003-Improve-index_checkable-in-amcheck.patch text/x-diff 2.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2025-05-29 02:49:47 Re: PG 18 release notes draft committed
Previous Message Michael Paquier 2025-05-29 02:30:12 Re: queryId constant squashing does not support prepared statements