Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOKze-0000JA-Uw for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Sep 2021 14:25:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mOKzd-0007fr-66 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Sep 2021 14:25:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOKzc-0007fj-Ud for pgsql-hackers@lists.postgresql.org; Thu, 09 Sep 2021 14:25:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOKza-0002KD-Un for pgsql-hackers@postgresql.org; Thu, 09 Sep 2021 14:25:32 +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 189EPRQw3606136; Thu, 9 Sep 2021 10:25:27 -0400 From: Tom Lane To: Christoph Berg cc: PostgreSQL Hackers Subject: Re: trap instead of error on 32 TiB table In-reply-to: References: <3568228.1631195095@sss.pgh.pa.us> Comments: In-reply-to Christoph Berg message dated "Thu, 09 Sep 2021 16:04:29 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3606134.1631197527.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 09 Sep 2021 10:25:27 -0400 Message-ID: <3606135.1631197527@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Christoph Berg writes: >> Can you provide a stack trace from that? > #2 0x0000558b6223d46e in ExceptionalCondition (conditionName=3Dconditio= nName@entry=3D0x558b623b2577 "tagPtr->blockNum !=3D P_NEW", > errorType=3DerrorType@entry=3D0x558b6229b016 "FailedAssertion", > fileName=3DfileName@entry=3D0x558b623b2598 "./build/../src/backend/s= torage/buffer/buf_table.c", lineNumber=3DlineNumber@entry=3D125) > at ./build/../src/backend/utils/error/assert.c:67 > #3 0x0000558b620bafb9 in BufTableInsert (tagPtr=3DtagPtr@entry=3D0x7ffe= c8919330, hashcode=3Dhashcode@entry=3D960067002, buf_id=3D) > at ./build/../src/backend/storage/buffer/buf_table.c:125 > #4 0x0000558b620bf827 in BufferAlloc (foundPtr=3D0x7ffec891932b, strate= gy=3D0x0, blockNum=3D4294967295, forkNum=3DMAIN_FORKNUM, > relpersistence=3D112 'p', smgr=3D0x558b62ed4b38) at ./build/../src/b= ackend/storage/buffer/bufmgr.c:1234 Ah, thanks. I don't think it's unreasonable for BufTableInsert to contain that assertion --- we shouldn't be trying to allocate a buffer for an illegal block number. The regular error comes from mdextend, but that is too late under this worldview, because smgrextend expects to be given a zero-filled buffer to write out. I think where we ought to be making the check is right where ReadBuffer_common replaces P_NEW: /* Substitute proper block number if caller asked for P_NEW */ if (isExtend) + { blockNum =3D smgrnblocks(smgr, forkNum); + if (blockNum =3D=3D InvalidBlockNumber) + ereport(ERROR, + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("cannot extend file \"%s\" beyond %u blocks", + relpath(smgr->smgr_rnode, forkNum), + InvalidBlockNumber))); + } Having done that, the check in md.c could be reduced to an Assert, although there's something to be said for leaving it as-is as an extra layer of defense. regards, tom lane