Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubH5H-00Fwfe-Ey for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jul 2025 11:10:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ubH5F-006bNi-1A for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jul 2025 11:10:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubH5E-006bNa-O3 for pgsql-hackers@lists.postgresql.org; Mon, 14 Jul 2025 11:10:57 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ubH5A-007VBv-1Z for pgsql-hackers@lists.postgresql.org; Mon, 14 Jul 2025 11:10:57 +0000 Received: from [192.168.11.3] (p1696134-ipoe.ipoe.ocn.ne.jp [118.0.93.133]) by oss.nttdata.com (Postfix) with ESMTPSA id 990CE613B4; Mon, 14 Jul 2025 20:10:44 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: Date: Mon, 14 Jul 2025 20:10:40 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Assertion failure in smgr.c when using pg_prewarm with partitioned tables To: Masahiro Ikeda Cc: Fujii Masao , Dilip Kumar , Richard Guo , PostgreSQL Hackers References: <1cf7a731-024b-4421-8f09-b67b5c25df93@email.android.com> <591e4384-87c1-46b6-a4f2-144738f24956@oss.nttdata.com> <23d5aea0-be92-4837-a5ee-1bdf0ebc49c5@oss.nttdata.com> <548d2eb7ae9d1ff4c8cc7e4e3251b8d3@oss.nttdata.com> <1a3170ba-a2d2-4519-be04-6b620f698be3@oss.nttdata.com> Content-Language: en-US From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025/07/14 17:13, Masahiro Ikeda wrote: > On 2025-07-04 20:32, Fujii Masao wrote: >> On 2025/06/02 16:32, Masahiro Ikeda wrote: >>> OK, I think v5-0002 should be back-patched, since using incorrect error codes is essentially a bug. >> >> Thanks for updating the patches! >> >> While reviewing the code: >> >>                 amtup = SearchSysCache1(AMOID, ObjectIdGetDatum(am_id)); >>                 amtuprel = SearchSysCache1(AMOID, >> ObjectIdGetDatum(rel->rd_rel->relam)); >>                 ereport(ERROR, >> - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), >> +                               (errcode(ERRCODE_WRONG_OBJECT_TYPE), >>                                  errmsg("expected \"%s\" index as >> targets for verification", NameStr(((Form_pg_am) >> GETSTRUCT(amtup))->amname)), >>                                  errdetail("Relation \"%s\" is a %s index.", >> >> RelationGetRelationName(rel), NameStr(((Form_pg_am) >> GETSTRUCT(amtuprel))->amname)))); >> >> I initially thought switching to ERRCODE_WRONG_OBJECT_TYPE made sense, >> but after checking similar cases, I'm reconsidering. For instance, >> pgstat_relation() in pgstattuple.c uses ERRCODE_FEATURE_NOT_SUPPORTED >> when the access method is unexpected. That suggests using >> FEATURE_NOT_SUPPORTED here may not be incorrect. > > OK, that seems reasonable to me. > >>         if (!rel->rd_index->indisvalid) >>                 ereport(ERROR, >> - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), >> + >> (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), >>                                  errmsg("cannot check index \"%s\"", >> RelationGetRelationName(rel)), >>                                  errdetail("Index is not valid."))); >> >> Other parts of the codebase (including pgstattuple) use >> ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE when rejecting invalid index. >> So, changing to this error code still seems reasonable and more >> consistent overall. >> >> Given that, I'd like to merge just this error code change from >> the 0002 patch into 0003, and apply the combined patch to >> the master branch only. Although I briefly considered backpatching >> the change of error code, it could be seen as a behavioral change, >> and the existing error code doesn't cause any real problem in older >> branches. So it's probably better to leave it as-is there. >> >> The updated patch is attached. It also changes index_checkable() >> from extern to static, since it's only used within verify_common.c. >> >> Thoughts? > > Thanks for updating the patch. I agree with your idea. > BTW, is "witha" a typo in the commit message? Aside from that, I have > no additional comments on your patch. Thanks for the review! You're right, that was a typo. I've fixed it and pushed the patch. Thanks! Regards, -- Fujii Masao NTT DATA Japan Corporation