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 1s4PR1-003bsp-4P for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 18:21:02 +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 1s4PQx-004UPF-LH for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 18:21:00 +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.94.2) (envelope-from ) id 1s4PQx-004UP7-Bk for pgsql-hackers@lists.postgresql.org; Tue, 07 May 2024 18:21:00 +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.94.2) (envelope-from ) id 1s4PQv-001uSG-PC for pgsql-hackers@lists.postgresql.org; Tue, 07 May 2024 18:20:58 +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 447IKti8076911; Tue, 7 May 2024 14:20:55 -0400 From: Tom Lane To: Andrew Dunstan cc: Richard Guo , David Rowley , jian he , PostgreSQL Hackers Subject: Re: Revert: Remove useless self-joins *and* -DREALLOCATE_BITMAPSETS make server crash, regress test fail. In-reply-to: <1e6ca7b3-98e6-46b2-9982-97f92c7523d8@dunslane.net> References: <1e6ca7b3-98e6-46b2-9982-97f92c7523d8@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Tue, 07 May 2024 08:00:25 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <76886.1715106032.0@sss.pgh.pa.us> Date: Tue, 07 May 2024 14:20:55 -0400 Message-ID: <76910.1715106055@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <76886.1715106032.1@sss.pgh.pa.us> Andrew Dunstan writes: > On 2024-05-07 Tu 06:05, Richard Guo wrote: >> +1 to have build farm coverage of REALLOCATE_BITMAPSETS. This flag >> seems quite useful. > I have added it to the CPPFLAGS on prion. ... and as expected, prion fell over. I find that Richard's proposed fix makes the core regression tests pass, but we still fail check-world. So I'm afraid we need something more aggressive, like the attached which makes make_restrictinfo copy all its input bitmapsets. Without that, we still have sharing of bitmapsets across different RestrictInfos, which seems pretty scary given what we now see about the effects of 00b41463c. This seems annoyingly expensive, but maybe there's little choice? Given this, we could remove ad-hoc bms_copy calls from the callers of make_restrictinfo, distribute_quals_to_rels, etc. I didn't go looking for possible wins of that sort; there's unlikely to be a lot of them. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="copy-bitmapsets-when-making-restrictinfos.patch"; charset="us-ascii" Content-ID: <76886.1715106032.2@sss.pgh.pa.us> Content-Description: copy-bitmapsets-when-making-restrictinfos.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optim= izer/util/restrictinfo.c index 0b406e9334..e81861bc8b 100644 --- a/src/backend/optimizer/util/restrictinfo.c +++ b/src/backend/optimizer/util/restrictinfo.c @@ -132,8 +132,8 @@ make_restrictinfo_internal(PlannerInfo *root, restrictinfo->is_clone =3D is_clone; restrictinfo->can_join =3D false; /* may get set below */ restrictinfo->security_level =3D security_level; - restrictinfo->incompatible_relids =3D incompatible_relids; - restrictinfo->outer_relids =3D outer_relids; + restrictinfo->incompatible_relids =3D bms_copy(incompatible_relids); + restrictinfo->outer_relids =3D bms_copy(outer_relids); = /* * If it's potentially delayable by lower-level security quals, figure o= ut @@ -191,7 +191,7 @@ make_restrictinfo_internal(PlannerInfo *root, = /* required_relids defaults to clause_relids */ if (required_relids !=3D NULL) - restrictinfo->required_relids =3D required_relids; + restrictinfo->required_relids =3D bms_copy(required_relids); else restrictinfo->required_relids =3D restrictinfo->clause_relids; = ------- =_aaaaaaaaaa0--