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 1uiv0y-0004gl-2R for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Aug 2025 13:14:08 +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 1uiv0w-001NNZ-JT for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Aug 2025 13:14:06 +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 1uiv0w-001NNR-9T for pgsql-bugs@lists.postgresql.org; Mon, 04 Aug 2025 13:14:06 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uiv0t-000hm5-2F for pgsql-bugs@lists.postgresql.org; Mon, 04 Aug 2025 13:14:05 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-6153a19dddfso6742682a12.1 for ; Mon, 04 Aug 2025 06:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754313242; x=1754918042; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xYjmLibvabixOvJTDfRjo2dV4HOBPzVgKjrsAHnO5fg=; b=giQJhD6Ky2yQDqTZXA/P7ohMtit2RcYxMMZTMzWUhR+8HUaD5eDKefwdMOALXHSlsA hEnqEf43wbSX7Ei5SgO+Wiy3l7uTZEyl87VxETCUq0zx1CEEHRqt1RqZy8QeUvWN0awX nVz/admigoO/gYVSLLLtCYInDukaf7Lk+OPgCWL4aD4FyXXbQ340YsFbWTm/ccSi6X3Y TgExGSMxIvykoRu8JXpv9HS+WQbdtCj+pGvydSYq9o3cQ5FvzlLPmBLot63pdmt8/Wtv DGy4rN6nm0a8AgQxWgR5/2SI4IsPTuGWUaa6v9jRR4OqeIklFzB1mfwvDBCeLGgm1CBT tG+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754313242; x=1754918042; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xYjmLibvabixOvJTDfRjo2dV4HOBPzVgKjrsAHnO5fg=; b=EMdsQ0fLmX/Nq5hDRHdOoCsGj4Bs4gJjZZ9+87kZFjV3hLA9ASww7NRhEaa+4jb9kE 4BgW2FU0CPkNDs/Bj4p69WJVTv7Zf/MQfmJNoQZBKopadVqWu1o8/kIai1s+XDNVCZwr cKYrWGOEnnRAGpNFZyS80o7KywCgePOzl8Xt94ePXfWNNoA8QJpyfu92BYoRL+elo4/4 xTt5j8ugTFkUFKdVdbTOLoSkwzWTLTmXYBpHwj+EVGfKtDJCK2AEr0odLcegdIaMqbX4 cv+liGqYMi6c5neybqmN10cnh77pCQK+5TM2U8rdzTNFBdhq6i83F1W1DBGIUy/Ame6Z PF9A== X-Forwarded-Encrypted: i=1; AJvYcCXGBu3uK32+TMjPw4WJkxuN8fUnFf3onGBG9eixZTl2pGSFhD261HTvUGavILekTEV6M6JMnVpRsIBB@lists.postgresql.org X-Gm-Message-State: AOJu0YzkHyH6csofHKfMwoYchUoM/js3IKhzfoxA2Tac6HDbL5V6fzOZ ijddVwKO/3w+k3ig8mVqC0XOj2IK5PTPzEutVcPojwWzVO1oy2yHRb8NdnUroRI97asAnR0lp/J Fa8kH7eKY/13htTGt6OG/C3YdfnS7JR8Q0+p/oQgpiQ== X-Gm-Gg: ASbGncuSqj6gQBGzxN7txk7UILqjsGkzXZWyo4990HlZfSZ9MUbm85QiyNH3DFxYW+I EP1xQYMOv/PtLxF3ZExUe7SFNU6g1grGIxbwmyKuaJARms/xCdX5K4eF61gf29v8whyFizrjmXc dHmyNDNHfIkfEubq6JrhuHAvlUJr0mXuYEttBDTzkgjVkAU8hL5fVWR00JZFVIZQJpkSNz/oI/h BVNsQMV X-Google-Smtp-Source: AGHT+IF+5MCyJwo1Q8N2ybSVawj2zk9PuyinFEdspE6Lc35cBi4QlPhNrqXM7RJSSwgrN2vdgW+Dt2vguow07jO7ah0= X-Received: by 2002:a17:907:72cd:b0:ae0:c0b3:5648 with SMTP id a640c23a62f3a-af93ffc06fbmr905724066b.1.1754313241726; Mon, 04 Aug 2025 06:14:01 -0700 (PDT) MIME-Version: 1.0 References: <19006-80fcaaf69000377e@postgresql.org> In-Reply-To: <19006-80fcaaf69000377e@postgresql.org> From: Xuneng Zhou Date: Mon, 4 Aug 2025 21:13:47 +0800 X-Gm-Features: Ac12FXy1I-5KunRPPbbIYGZqQvXdKwiTeDwCkhX6S2oCI68Xa6cSNil8SvTNXvk Message-ID: Subject: Re: BUG #19006: Assert(BufferIsPinned) in BufferGetBlockNumber() is triggered for forwarded buffer To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Cc: thomas.munro@gmail.com, Michael Paquier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Sun, Aug 3, 2025 at 8:58=E2=80=AFPM PG Bug reporting form wrote: > > The following bug has been logged on the website: > > Bug reference: 19006 > Logged by: Alexander Lakhin > Email address: exclusion@gmail.com > PostgreSQL version: 18beta2 > Operating system: Ubuntu 24.04 > Description: > > The following script (based on the regress scripts): > CREATE TABLE public.tenk1 ( > unique1 integer, > unique2 integer, > two integer, > four integer, > ten integer, > twenty integer, > hundred integer, > thousand integer, > twothousand integer, > fivethous integer, > tenthous integer, > odd integer, > even integer, > stringu1 name, > stringu2 name, > string4 name > ); > > COPY tenk1 FROM '.../src/test/regress/data/tenk.data'; > COPY tenk1 FROM '.../src/test/regress/data/tenk.data'; > DELETE FROM tenk1; > COPY tenk1 FROM '.../src/test/regress/data/tenk.data'; > > SELECT COUNT(*) FROM tenk1 t1 LEFT JOIN > LATERAL (SELECT t1.twenty, t2.two FROM tenk1 t2) s > ON t1.two =3D s.two > WHERE s.twenty < 0; > > with > shared_buffers =3D 16MB > triggers: > TRAP: failed Assert("BufferIsPinned(buffer)"), File: "bufmgr.c", Line: 42= 33, > PID: 2785555 > > Core was generated by `postgres: law regression [local] SELECT > '. > Program terminated with signal SIGABRT, Aborted. > ... > #0 __pthread_kill_implementation (no_tid=3D0, signo=3D6, threadid=3D out>) at ./nptl/pthread_kill.c:44 > #1 __pthread_kill_internal (signo=3D6, threadid=3D) at > ./nptl/pthread_kill.c:78 > #2 __GI___pthread_kill (threadid=3D, signo=3Dsigno@entry= =3D6) at > ./nptl/pthread_kill.c:89 > #3 0x000075efce04527e in __GI_raise (sig=3Dsig@entry=3D6) at > ../sysdeps/posix/raise.c:26 > #4 0x000075efce0288ff in __GI_abort () at ./stdlib/abort.c:79 > #5 0x00006419a43d5e3f in ExceptionalCondition > (conditionName=3DconditionName@entry=3D0x6419a445bb56 "BufferIsPinned(buf= fer)", > fileName=3DfileName@entry=3D0x6419a445b9b7 "bufmgr.c", > lineNumber=3DlineNumber@entry=3D4233) at assert.c:66 > #6 0x00006419a423f028 in BufferGetBlockNumber (buffer=3D)= at > bufmgr.c:4233 > #7 0x00006419a42445c5 in StartReadBuffersImpl (allow_forwarding=3Dtrue, > flags=3D0, nblocks=3D0x7fff9765ee74, blockNum=3D710, buffers=3D0x6419bc3d= 127c, > operation=3D0x6419bc3d1428) at bufmgr.c:1292 > #8 StartReadBuffers (operation=3D0x6419bc3d1428, > buffers=3Dbuffers@entry=3D0x6419bc3d127c, blockNum=3D710, > nblocks=3Dnblocks@entry=3D0x7fff9765ee74, flags=3Dflags@entry=3D0) at buf= mgr.c:1500 > #9 0x00006419a423afc4 in read_stream_start_pending_read > (stream=3Dstream@entry=3D0x6419bc3d1218) at read_stream.c:335 > #10 0x00006419a423b3df in read_stream_look_ahead > (stream=3Dstream@entry=3D0x6419bc3d1218) at read_stream.c:493 > #11 0x00006419a423b7b3 in read_stream_next_buffer (stream=3D0x6419bc3d121= 8, > per_buffer_data=3Dper_buffer_data@entry=3D0x0) at read_stream.c:971 > #12 0x00006419a3efaede in heap_fetch_next_buffer (dir=3D, > scan=3D0x6419bc3d0cf8) at heapam.c:675 > #13 heapgettup_pagemode (scan=3Dscan@entry=3D0x6419bc3d0cf8, dir=3D out>, nkeys=3D, key=3D) at heapam.c:1037 > #14 0x00006419a3efb5d2 in heap_getnextslot (sscan=3D0x6419bc3d0cf8, > direction=3D, slot=3D0x6419bc3c11a8) at heapam.c:1391 > #15 0x00006419a40d1503 in table_scan_getnextslot (slot=3D0x6419bc3c11a8, > direction=3DForwardScanDirection, sscan=3D) at > ../../../src/include/access/tableam.h:1031 > #16 SeqNext (node=3Dnode@entry=3D0x6419bc3c0f88) at nodeSeqscan.c:81 > #17 0x00006419a40d197f in ExecScanFetch (recheckMtd=3D0x6419a40d1490 > , accessMtd=3D0x6419a40d14a0 , epqstate=3D0x0, > node=3D) at ../../../src/include/executor/execScan.h:126 > #18 ExecScanExtended (projInfo=3D0x0, qual=3D0x6419bc38a650, epqstate=3D0= x0, > recheckMtd=3D0x6419a40d1490 , accessMtd=3D0x6419a40d14a0 , > node=3D0x6419bc3c0f88) at ../../../src/include/executor/execScan.h:187 > #19 ExecSeqScanWithQual (pstate=3D0x6419bc3c0f88) at nodeSeqscan.c:138 > #20 0x00006419a40cf97b in ExecProcNode (node=3D0x6419bc3c0f88) at > ../../../src/include/executor/executor.h:313 > #21 ExecNestLoop (pstate=3D) at nodeNestloop.c:159 > ... > > Reproduced starting from 12ce89fd0. > Thanks for reporting this. I can reproduce this issue reliably when shared_buffers is set to 16 MB; raising the value allows the query to complete normally. However, I don't have the expertise to investigate and fix it. Perhaps we could CC Thomas on this thread to see whether he might have time to look into it. Best, Xuneng