Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9fIg-0004Y0-0c for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2017 22:46:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e9fIf-0005bR-I2 for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2017 22:46:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e9fH3-0008CN-5S for pgsql-hackers@postgresql.org; Tue, 31 Oct 2017 22:44:45 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e9fGz-0000nN-EL for pgsql-hackers@postgresql.org; Tue, 31 Oct 2017 22:44:44 +0000 Received: by mail-wm0-x231.google.com with SMTP id y83so1746235wmc.4 for ; Tue, 31 Oct 2017 15:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=6FTGmIo84TyWXVXHh/UW+jv9sRkCr0zE3hfKMUAAtMo=; b=f9q4lpKlTWR/nttBckuq01EMO3BN2w09YUy/iCHhUPp0br04905OYieZowVL8DHqBo S0QbPUxm+rUejiGbNniDkTGYUvJTu+sfeQ/eNSnJZJSVhyh7XlQmrIH+yZhKXM3kzhzq 3ejxCJFBYcUwbEhm7xblQucuGrEhJ4QqPY+OVA7i7p01tjxd0/lfITYRf0wh6tYHP1PB vKDRiBJvz8LPFgvvEhMXj0Wzr//tzJu+eYl/NHMb51HV+hDVAFqcmh46UTRKriPXDBVf 48TiXMjAbAvenwXKP9fSq+ADuh6hfmm14FzCihv54ujbfdhFags4Fci1K9PjVLtjxC82 OFxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=6FTGmIo84TyWXVXHh/UW+jv9sRkCr0zE3hfKMUAAtMo=; b=sc7Wf4dsibR0Skt9GqCz3oBUTdlgO66IumIoY9EFxjIOpdjxjHHJw3VDlCw87ibjBU vwt2+NgF60lxpBmHc91/pSCa7PfdewqHSQ+f7G+Ru+EfTeKXXvhlKPJkfIV5xNaDzU8A C0Jxadhkv6Y5y3wHQul8iJMkRN6kqHezvfSIFraBFAamyxy93IVEIgJ9QSxCmNH4C3R/ 8EOty0gtb2PX/aJmx0GKRCnt4eLDsNvdW4t6S0Ai8L03NPnl2xvenKaldUnFnIB1Bi5+ cUZCeAQX8LFEMfX9vkQ/kgdGMEmU84o6Pv4lBAliZEDYjZVKB8eamC3dJWEbdXNXbl1j m6tA== X-Gm-Message-State: AMCzsaV7xW6ARBQYtp328RS9LTzNhrRvhHecUL4F8jEjfN0sywjPy+ZM 6/bkjbn8tJZHs1G5EQTA2jOu7kb+zuzi4v75qS8SQeBo1AsWzWHZlwEuBBdUSJXAYQK4QtNAZfX P6x+OGcbO69idup2Ugd76bUsCFqEqla/PdnYpV7atUbaM3utCqSZSgDYPRMUl5m4oKUPxcHWZid NXBSEjKvY7 X-Google-Smtp-Source: ABhQp+ScIFzvYjqRRws4oVv3QOLOzkKCYAGytUQTjpCgojdQ2odzI6r5kys3RgQy0NoxS1EChR2CfA== X-Received: by 10.28.11.138 with SMTP id 132mr3157101wml.89.1509489880019; Tue, 31 Oct 2017 15:44:40 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id n14sm3071709wrg.38.2017.10.31.15.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 15:44:39 -0700 (PDT) Subject: Re: Re: PANIC: invalid index offnum: 186 when processing BRIN indexes in VACUUM To: Tom Lane , Alvaro Herrera Cc: Michael Paquier , PostgreSQL mailing lists References: <20171031181053.xh7hzminpv6rvwr2@alvherre.pgsql> <11499.1509476951@sss.pgh.pa.us> <13135.1509479192@sss.pgh.pa.us> From: Tomas Vondra Message-ID: <083d996a-4a8a-0e13-800a-851dd09ad8cc@2ndquadrant.com> Date: Tue, 31 Oct 2017 23:44:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <13135.1509479192@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------5F83F0ED1B296AF77FB2B2EE" Content-Language: en-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 This is a multi-part message in MIME format. --------------5F83F0ED1B296AF77FB2B2EE Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Hi, On 10/31/2017 08:46 PM, Tom Lane wrote: > 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. > That does fix the crashes for me - I've been unable to reproduce any even after one hour (it took a couple of minutes to crash before). Unfortunately, I think we still have a problem ... I've been wondering if we end up producing correct indexes, so I've done a simple test. 1) create the table as before 2) let the insert + vacuum run for some time, to see if there are crashes (result: no crashes after one hour, inserting ~92M rows) 3) do a bunch of random updates on the data (while still doing the concurrent vacuum in another session) 4) run a bunch of simple queries to compare the results, essentially -- BRIN index SET enable_bitmapscan = on; SELECT COUNT(*) FROM brin_test WHERE a = $1; -- seq scan SET enable_bitmapscan = on; SELECT COUNT(*) FROM brin_test WHERE a = $1; and unfortunately what I get is not particularly pleasant: test=# set enable_bitmapscan = on; SET test=# select count(*) from brin_test where a = 0; count ------- 9062 (1 row) test=# set enable_bitmapscan = off; SET test=# select count(*) from brin_test where a = 0; count ------- 9175 (1 row) Attached is a SQL script with commands I used. You'll need to copy the commands into multiple psql sessions, though, to simulate concurrent activity). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------5F83F0ED1B296AF77FB2B2EE Content-Type: application/sql; name="brin-test.sql" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="brin-test.sql" LS0gY3JlYXRlIHRhYmxlIGFuZCBpbmRleGVzIChvbmUgYnRyZWUgdXNlZCBi eSB0aGUgdXBkYXRlcyBsYXRlcikKY3JlYXRlIHRhYmxlIGJyaW5fdGVzdCAo aWQgaW50LCBhIGludCwgYiBiaWdpbnQsIGMgZmxvYXQsIGQgZG91YmxlIHBy ZWNpc2lvbiwgZSB1dWlkKTsKY3JlYXRlIGluZGV4IG9uIGJyaW5fdGVzdCAo aWQpOwpjcmVhdGUgaW5kZXggb24gYnJpbl90ZXN0IHVzaW5nIGJyaW4gKGEp IHdpdGggKHBhZ2VzX3Blcl9yYW5nZT0xNik7CmNyZWF0ZSBpbmRleCBvbiBi cmluX3Rlc3QgdXNpbmcgYnJpbiAoYikgd2l0aCAocGFnZXNfcGVyX3Jhbmdl PTE2KTsKY3JlYXRlIGluZGV4IG9uIGJyaW5fdGVzdCB1c2luZyBicmluIChj KSB3aXRoIChwYWdlc19wZXJfcmFuZ2U9MTYpOwpjcmVhdGUgaW5kZXggb24g YnJpbl90ZXN0IHVzaW5nIGJy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F83F0ED1B296AF77FB2B2EE 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 --------------5F83F0ED1B296AF77FB2B2EE--