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 1r1JAn-00ATlc-Vj for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Nov 2023 04:31:13 +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 1r1JAm-001PHS-2h for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Nov 2023 04:31:12 +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 1r1JAl-001PHK-QK for pgsql-bugs@lists.postgresql.org; Fri, 10 Nov 2023 04:31:11 +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.94.2) (envelope-from ) id 1r1JAe-005fqW-Uz for pgsql-bugs@lists.postgresql.org; Fri, 10 Nov 2023 04:31:11 +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 3AA4V28Q1303020; Thu, 9 Nov 2023 23:31:02 -0500 From: Tom Lane To: Jeff Janes cc: pgsql-bugs Subject: Re: Bug with GIN index over JSONB data: "ERROR: buffer 10112 is not owned by resource owner" In-reply-to: References: Comments: In-reply-to Jeff Janes message dated "Thu, 09 Nov 2023 20:44:21 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1302839.1699590592.0@sss.pgh.pa.us> Date: Thu, 09 Nov 2023 23:31:02 -0500 Message-ID: <1303019.1699590662@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: <1302839.1699590592.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Jeff Janes writes: > I was looking into a possible scalability problem with GIN indexes under > concurrent insert, but instead I found an uncharacterized bug. One of th= e > processes will occasionally throw an error "ERROR: buffer 10112 is not > owned by resource owner Portal" where the buffer number changes from run= to > run. I am able to reproduce this in HEAD (8bfb231b4) on a not-that-big machine (M2 Mac Mini): pgbench: error: client 1 script 0 aborted in command 0 query 0: ERROR: bu= ffer pin 0x1cab is not owned by resource owner Portal pgbench: error: Run was aborted; the above results are incomplete. FTR, I used the attached not-so-ubuntu-specific script, and a very vanilla assert-enabled build. However, it seems like there might be more than one bug. My first attempt died like this after a few minutes: TRAP: failed Assert("ref !=3D NULL"), File: "bufmgr.c", Line: 2447, PID: 7= 177 0 postgres 0x0000000102caab74 ExceptionalCond= ition + 108 1 postgres 0x0000000102b46490 UnpinBuffer + 5= 28 2 postgres 0x000000010282bae4 ginFinishSplit = + 1700 3 postgres 0x00000001028368ac ginEntryInsert = + 904 4 postgres 0x0000000102837194 gininsert + 472 5 postgres 0x00000001029bf77c ExecInsertIndex= Tuples + 552 6 postgres 0x00000001029ed0d4 ExecInsert + 19= 48 7 postgres 0x00000001029ebbfc ExecModifyTable= + 1252 8 postgres 0x00000001029c0dc4 standard_Execut= orRun + 268 9 postgres 0x0000000102b86450 ProcessQuery + = 160 10 postgres 0x0000000102b85afc PortalRunMulti = + 396 11 postgres 0x0000000102b85478 PortalRun + 476 12 postgres 0x0000000102b8453c exec_simple_que= ry + 1312 13 postgres 0x0000000102b82250 PostgresMain + = 3452 That was while running a build of commit 9ba9c7074 from 25 October. After updating to current HEAD (8bfb231b4), I've not yet reproduced it. But I suspect that's just bad luck, because this doesn't look like anything we fixed in the last couple weeks. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-shellscript; name="cloud_init_gin_bug"; charset="us-ascii" Content-ID: <1302839.1699590592.2@sss.pgh.pa.us> Content-Description: cloud_init_gin_bug Content-Transfer-Encoding: quoted-printable #!/bin/bash dropdb test createdb test export PGDATABASE=3Dtest psql -c ' create table j (id bigserial, j jsonb); create index on j using gin (j); alter index j_j_idx set (fastupdate =3D off); ' psql -c ' alter system set synchronous_commit to off; ' pg_ctl reload for g in `seq 1 100`; do for f in `seq 1 10`; do echo "trying with $f clients" psql -c 'truncate j' pgbench -n -f <(echo 'insert into j (j) select jsonb_object_agg(x::tex= t, left(md5(random()::text),5)) from generate_series(1,10) f(x);') -T 60 -= c $f -j $f | grep tps done done ------- =_aaaaaaaaaa0--