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

From: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(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-16 06:21:11
Message-ID: 8829854bbfc8635ddecd0846bb72dfda@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thank you for your comments!

I updated the patch to use RELKIND_HAS_STORAGE() as done in
commit 4623d7144. Please see the v2-0001 patch for the changes.

On 2025-05-15 19:57, Richard Guo wrote:
> +1. FWIW, not long ago we fixed a similar Assert failure in
> contrib/pg_freespacemap by verifying RELKIND_HAS_STORAGE() before
> trying to access the storage (see 4623d7144). Wondering if there are
> other similar issues elsewhere in contrib ...

I tested all contrib functions that take regclass arguments (see
attached test.sql and test_result.txt). The result shows that only
pg_prewarm() can lead to the assertion failure.

However, I found that amcheck's error messages can be misleading
when run on partitioned indexes.

For example, on the master branch, amcheck (e.g., bt_index_check
function)
shows this error:

> ERROR: expected "btree" index as targets for verification
> DETAIL: Relation "pgbench_accounts_pkey" is a btree index.

This message says it expects a "btree" index, yet also states the
relation
is a "btree" index, which can seem contradictory. The actual issue is
that
the index is a btree partitioned index, but this detail is missing,
causing
possible confusion.

Therefore, I thought it would be better to update the detailed message
as shown in the v2-0002 patch:

* master with 0002 patch
> ERROR: expected "btree" index as targets for verification
> DETAIL: Relation "pgbench_accounts_pkey" is a btree partitioned
index.

Regards,
--
Masahiro Ikeda
NTT DATA CORPORATION

Attachment Content-Type Size
test.sql text/plain 7.2 KB
v2-0001-Fix-assertion-failure-when-pg_prewarm-is-run-on-o.patch text/x-diff 2.7 KB
v2-0002-Fix-error-message-details-for-partitioned-indexes.patch text/x-diff 1.8 KB
test_result.txt text/plain 20.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2025-05-16 06:30:55 Re: Conflict detection for update_deleted in logical replication
Previous Message shveta malik 2025-05-16 05:45:20 Re: Conflict detection for update_deleted in logical replication