Re: Amcheck verification of GiST and GIN

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>, Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Andrey Borodin <amborodin86(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Jose Arthur Benetasso Villanova <jose(dot)arthur(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Amcheck verification of GiST and GIN
Date: 2024-07-10 16:01:40
Message-ID: 7849efb9-af39-491e-a931-6ea5d1fe8f23@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 7/9/24 08:36, Andrey M. Borodin wrote:
>
>
>> On 5 Jul 2024, at 17:27, Andrey M. Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
>>
>> There’s one more problem in pg_amcheck’s GiST verification. We must
>> check that amcheck is 1.5+ and use GiST verification only in that
>> case …
>
> Done. I’ll set the status to “Needs review”.
>

I realized amcheck GIN/GiST support would be useful for testing my
patches adding parallel builds for these index types, so I decided to
take a look at this and do an initial review today.

Attached is a patch series with a extra commits to keep the review
comments and patches adjusting the formatting by pgindent (the patch
seems far enough for this).

Let me quickly go through the review comments:

1) Not sure I like 'amcheck.c' very much, I'd probably go with something
like 'verify_common.c' to match naming of the other files. But it's just
nitpicking and I can live with it.

2) amcheck_lock_relation_and_check seems to be the most important
function, yet there's no comment explaining what it does :-(

3) amcheck_lock_relation_and_check still has a TODO to add the correct
name of the AM

4) Do we actually need amcheck_index_mainfork_expected as a separate
function, or could it be a part of index_checkable?

5) The comment for heaptuplespresent says "debug counter" but that does
not really explain what it's for. (I see verify_nbtree has the same
comment, but maybe let's improve that.)

6) I'd suggest moving the GISTSTATE + blocknum fields to the beginning
of GistCheckState, it seems more natural to start with "generic" fields.

7) I'd adjust the gist_check_parent_keys_consistency comment a bit, to
explain what the function does first, and only then explain how.

8) We seem to be copying PageGetItemIdCareful() around, right? And the
copy in _gist.c still references nbtree - I guess that's not right.

9) Why is the GIN function called gin_index_parent_check() and not
simply gin_index_check() as for the other AMs?

10) The debug in gin_check_posting_tree_parent_keys_consistency triggers
assert when running with client_min_messages='debug5', it seems to be
accessing bogus item pointers.

11) Why does it add pg_amcheck support only for GiST and not GIN?

That's all for now. I'll add this to the stress-testing tests of my
index build patches, and if that triggers more issues I'll report those.

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
v28-review-0001-Refactor-amcheck-to-extract-common-lockin.patch text/x-patch 19.9 KB
v28-review-0002-review.patch text/x-patch 1.8 KB
v28-review-0003-pgindent.patch text/x-patch 2.6 KB
v28-review-0004-Add-gist_index_check-function-to-verify-G.patch text/x-patch 33.8 KB
v28-review-0005-review.patch text/x-patch 4.9 KB
v28-review-0006-pgindent.patch text/x-patch 10.5 KB
v28-review-0007-Add-gin_index_parent_check-to-verify-GIN-.patch text/x-patch 32.3 KB
v28-review-0008-review.patch text/x-patch 1.3 KB
v28-review-0009-pgindent.patch text/x-patch 2.1 KB
v28-review-0010-Add-GiST-support-to-pg_amcheck.patch text/x-patch 34.4 KB
v28-review-0011-review.patch text/x-patch 726 bytes
v28-review-0012-pgindent.patch text/x-patch 5.7 KB
v28-review-0013-assert-in-GIN-debug-message.patch text/x-patch 1.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2024-07-10 16:02:25 Re: Add a GUC check hook to ensure summarize_wal cannot be enabled when wal_level is minimal
Previous Message Greg Sabino Mullane 2024-07-10 15:58:01 Send duration output to separate log files