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 1m6T5e-0003tX-UU for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Jul 2021 07:25:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m6T5d-0002db-Mf for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Jul 2021 07:25:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6T5c-0002dS-Vl for pgsql-bugs@lists.postgresql.org; Thu, 22 Jul 2021 07:25:53 +0000 Received: from meesny.iki.fi ([195.140.195.201]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6T5Y-0007Fn-2N for pgsql-bugs@lists.postgresql.org; Thu, 22 Jul 2021 07:25:51 +0000 Received: from [192.168.1.113] (dsl-hkibng22-54faa4-119.dhcp.inet.fi [84.250.164.119]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 5E884200CE; Thu, 22 Jul 2021 10:25:43 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1626938743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=S2K+2juBBXwLj49ic3SisyYPlDasyZPytB6GAeicnEM=; b=IDCh23VrjPwjbt37jfZsakQin/4qfNAgHccKXh29Ggt0ulJxFiIGm+PI4w+3Nnnty4jTzi LhjywOEm04LnxW7kx2bgBSCNPge3SUM7xSUk78O2aQ940j1TruUvsF5Oo+tKkq0Dh+JSMD 2O4cLwSAXMp+O3ai/sgqbl7BNC820YE= Subject: Re: IRe: BUG #16792: silent corruption of GIN index resulting in SELECTs returning non-matching rows To: Pawel Kudzia Cc: Peter Geoghegan , Alexander Korotkov , PostgreSQL mailing lists , Tom Lane References: <16792-b1913b6b4e098331@postgresql.org> <920041ab-e975-afe3-77d0-934a7c50965d@iki.fi> <06cedb17-6cbe-6586-caa6-2ff618a35517@iki.fi> <470ba78f-4784-f90d-91ba-dcc05d6d4738@iki.fi> <14dfcfab-36df-a92d-a42c-01065acf0036@iki.fi> <8b21e29c-f236-ef40-452f-3fb829b37990@iki.fi> From: Heikki Linnakangas Message-ID: <9fdbb584-1e10-6a55-ecc2-9ba8b5dca1cf@iki.fi> Date: Thu, 22 Jul 2021 10:25:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------2EA3246A77B82151CCF0F806" Content-Language: en-US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1626938743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=S2K+2juBBXwLj49ic3SisyYPlDasyZPytB6GAeicnEM=; b=ohjySbpALoirBpe1OsMMikUo1ecy45PiKTTlcX7tDzNsh33/AN+iqgHoR/+jOWQcvGRpKV j8jx+f1SOEhcG4Tiapw7ncBdP6jyDWxypvtDrE3D8O1VVkK4tZerx78A7jTQUXl2KaLS/J Aa8RATa5bQtDTCLSUg6PvspJscKTlHk= ARC-Seal: i=1; s=meesny; d=iki.fi; t=1626938743; a=rsa-sha256; cv=none; b=Kz/1hH/SOKaqfalALokE9vDiRT7prLI6e2HzaQ3XriZJjp+pIP8UEW41XEzr+o53em63OW 68JP7ySScxWk2FGyiglwnT9CwdY33IEZY1hNwVmV49iQCOSZqs0hPogI2+55awVKBxfubF jDxrE6m65Fb6Lm2XPn4ugzhxzSKZ7gg= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------2EA3246A77B82151CCF0F806 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 20/07/2021 18:58, Pawel Kudzia wrote: > On Tue, Jul 20, 2021 at 5:34 PM Heikki Linnakangas wrote: >> Pawel: Can you test once again with the attached amcheck version? > > patch v4-0001-Amcheck-for-GIN-13stable.patch applied to > postgresql-13_13.3.orig.tar.bz2 > attached - log and result of the check. > > executing "select > gin_index_parent_check('entity_attribute_name_ids_gin');" took > considerably longer this time and it ended with : > > [524767.920498] postgres[29716]: segfault at fffffffffffffffe ip > 00007f214c20a2d8 sp 00007ffe2a5fd040 error 5 in > amcheck.so[7f214c209000+6000] > [524767.920521] Code: 00 00 41 0f b7 4e 04 41 8b 56 0c 41 8b 76 10 49 > 89 c1 48 8d 04 40 c1 e1 10 45 0f b7 46 08 48 8d 7c 43 fa 41 0f b7 46 > 06 09 c1 <0f> b7 47 04 50 0f b7 07 0f b7 7f 02 c1 e0 10 09 f8 50 0f b7 > 43 04 Hmph, another set of bugs in the amcheck patch. It didn't handle empty entry tree items, nor empty posting tree pages. And there was another bug, which caused it to scan entry tree pages multiple times; that's why the same WARNING was printed multiple times. Fixed those bugs, new patch version attached. Pawel, can you test this again, please? At this point, I'm pretty sure this isn't going to reveal any more information about the original problem, but at least we're ironing out bugs from the 'amcheck' patch.. I'm grasping at straws here, but here's one more thing we could try: the query returned these incorrect tuples: ctid | entity_id --------------+----------- (4002784,1) | 38048120 (4002869,14) | 95333744 (2 rows) We know those entries are in the GIN index with key '1373', when they shouldn't be. But I wonder if the correct keys for those tuples are present? Pawel, can you try this, please: -- persuade planner to use a bitmap index scan set enable_seqscan=off; set enable_tidscan=off; -- avoid lossy bitmaps set work_mem='1GB'; -- Explain analyze first to check it's using a bitmap index scan and -- no lossy pages. explain analyze SELECT ctid, entity_id FROM entity WHERE attribute_name_ids && '{38048120}' and ctid='(4002784,1)'; SELECT ctid, entity_id FROM entity WHERE attribute_name_ids && '{38048120}' and ctid='(4002784,1)'; explain analyze SELECT ctid, entity_id FROM entity WHERE attribute_name_ids && '{95333744}' and ctid='(4002869,14)'; SELECT ctid, entity_id FROM entity WHERE attribute_name_ids && '{95333744}' and ctid='(4002869,14)'; - Heikki --------------2EA3246A77B82151CCF0F806 Content-Type: text/x-patch; charset=UTF-8; name="v5-0001-Amcheck-for-GIN-13stable.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v5-0001-Amcheck-for-GIN-13stable.patch"