Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9cUh-0002m2-Vf for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2017 19:46:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e9cUh-0000IQ-C4 for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2017 19:46:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e9cUf-0000FR-Di for pgsql-hackers@postgresql.org; Tue, 31 Oct 2017 19:46:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e9cUc-0003l4-Vu for pgsql-hackers@postgresql.org; Tue, 31 Oct 2017 19:46:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v9VJkWWO013136; Tue, 31 Oct 2017 15:46:32 -0400 From: Tom Lane To: Alvaro Herrera cc: Michael Paquier , Tomas Vondra , PostgreSQL mailing lists Subject: Re: Re: PANIC: invalid index offnum: 186 when processing BRIN indexes in VACUUM In-reply-to: <11499.1509476951@sss.pgh.pa.us> References: <20171031181053.xh7hzminpv6rvwr2@alvherre.pgsql> <11499.1509476951@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 31 Oct 2017 15:09:11 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <13077.1509479104.0@sss.pgh.pa.us> Date: Tue, 31 Oct 2017 15:46:32 -0400 Message-ID: <13135.1509479192@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13077.1509479104.1@sss.pgh.pa.us> I wrote: > maybe > we just have some run-of-the-mill bugs to find, like the off-the-end > bug I spotted in brin_doupdate. There's apparently at least one > more, but given the error message it must be something like not > checking for a page to have turned into a revmap page. Shouldn't > be too hard to find... Actually, I think it might be as simple as the attached. brin_getinsertbuffer checks for the old page having turned into revmap, but the "samepage" path in brin_doupdate does not :-( With this applied, Alvaro's version of the test case has survived without error for quite a bit longer than its former MTBF. There might still be some issues though in other code paths. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="fix-brin_doupdate.patch"; charset="us-ascii" Content-ID: <13077.1509479104.2@sss.pgh.pa.us> Content-Description: fix-brin_doupdate.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/br= in/brin_pageops.c index 80f803e..b0f86f3 100644 *** a/src/backend/access/brin/brin_pageops.c --- b/src/backend/access/brin/brin_pageops.c *************** brin_doupdate(Relation idxrel, BlockNumb *** 113,121 **** =20=20 /* * Check that the old tuple wasn't updated concurrently: it might have ! * moved someplace else entirely ... */ ! if (!ItemIdIsNormal(oldlp)) { LockBuffer(oldbuf, BUFFER_LOCK_UNLOCK); =20=20 --- 113,127 ---- =20=20 /* * Check that the old tuple wasn't updated concurrently: it might have ! * moved someplace else entirely, and for that matter the whole page ! * might've become a revmap page. Note that in the first two cases ! * checked here, the "oldlp" we just calculated is garbage; but ! * PageGetItemId() is simple enough that it was safe to do that ! * calculation anyway. */ ! if (!BRIN_IS_REGULAR_PAGE(oldpage) || ! oldoff > PageGetMaxOffsetNumber(oldpage) || ! !ItemIdIsNormal(oldlp)) { LockBuffer(oldbuf, BUFFER_LOCK_UNLOCK); =20=20 ------- =_aaaaaaaaaa0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers ------- =_aaaaaaaaaa0--