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.96) (envelope-from ) id 1wEyBw-004cns-1F for pgsql-committers@arkaria.postgresql.org; Mon, 20 Apr 2026 23:38:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEyBv-004tkg-0J for pgsql-committers@arkaria.postgresql.org; Mon, 20 Apr 2026 23:38:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEyBu-004tkO-2q for pgsql-committers@lists.postgresql.org; Mon, 20 Apr 2026 23:38:10 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wEyBs-00000001zpo-2UMb for pgsql-committers@lists.postgresql.org; Mon, 20 Apr 2026 23:38:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 63KNc6r9466112; Mon, 20 Apr 2026 19:38:06 -0400 From: Tom Lane To: Richard Guo cc: Michael Paquier , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Clean up all relid fields of RestrictInfos during join removal. In-reply-to: References: Comments: In-reply-to Richard Guo message dated "Tue, 21 Apr 2026 08:08:40 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <466110.1776728286.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 20 Apr 2026 19:38:06 -0400 Message-ID: <466111.1776728286@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Tue, Apr 21, 2026 at 8:03=E2=80=AFAM Michael Paquier wrote: >> prion looks unhappy on this one: >> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Dprion&dt=3D20= 26-04-20%2022%3A50%3A01 >> This uses -DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE. > This seems the same problem as in skink. Yeah, likely. As best I can tell, the reason skink is falling over is that USE_VALGRIND enables list.c's DEBUG_LIST_MEMORY_USAGE, making list.c much more memory-hungry and thus able to recycle freed bitmapset storage before it would have been recycled in a regular debug build. Probably prion's options have a similar effect. Wanting to get the buildfarm green again, I didn't stop to dig into this interesting question: how the heck did cfcd57111 manage to pass regression testing in our standard test rig with CLOBBER_FREED_MEMORY enabled? In the problematic cases, remove_rel_from_eclass reduces cur_em->em_relids to empty causing it to be pfree'd, which means that there is now some associated RestrictInfo whose left_relids or right_relids is pointing at freed memory. That should result in the later bms_del_member calls in remove_rel_from_restrictinfo blowing up instantly on Assert(bms_is_valid_set(a)). The only way that doesn't happen, AFAICS, is if we repopulate that freed chunk with another Bitmapset in between. It's certainly possible given that the loop in remove_rel_from_restrictinfo will do some bms_copy's, but you would not think it'd happen that way reliably enough to get through check-world. regards, tom lane