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 1tk7VG-000DvT-Jf for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Feb 2025 20:14:06 +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 1tk7UH-002eUw-9S for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Feb 2025 20:13:05 +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 1tk7UH-002eUn-1C for pgsql-bugs@lists.postgresql.org; Mon, 17 Feb 2025 20:13:05 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tk7UE-001Pzz-1w for pgsql-bugs@lists.postgresql.org; Mon, 17 Feb 2025 20:13:04 +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 51HKD0mm911899; Mon, 17 Feb 2025 15:13:00 -0500 From: Tom Lane To: Tomas Vondra cc: Sergey Belyashov , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18815: Logical replication worker Segmentation fault In-reply-to: <906545.1739821437@sss.pgh.pa.us> References: <18815-2a0407cc7f40b327@postgresql.org> <832225.1739810351@sss.pgh.pa.us> <906545.1739821437@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 17 Feb 2025 14:43:57 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <911897.1739823180.1@sss.pgh.pa.us> Date: Mon, 17 Feb 2025 15:13:00 -0500 Message-ID: <911898.1739823180@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > I suspect that the attached will fix it. What I don't understand > is why it's apparently so hard to trigger the crash, because it > looks to me like any two successive insert commands on the same > BRIN index should hit this. Oh, wait: I was confusing ii_AmCache with rd_amcache in the index's relcache entry. This coding would absolutely not work with rd_amcache since that's persistent. It mostly works with the IndexInfo field though, since an IndexInfo typically only survives per-query. Evidently there's some path in logical replication that will re-use an IndexInfo across multiple distinct insertion operations, and that's what breaks it. > BTW, I'm also a bit suspicious of the comment's claim that the > brinDesc doesn't need cleanup. That looks like a potential > memory leak. This concern still stands. regards, tom lane