Обсуждение: Re: bt_index_parent_check and concurrently build indexes

Поиск
Список
Период
Сортировка

Re: bt_index_parent_check and concurrently build indexes

От
"Andrey M. Borodin"
Дата:

> On 9 Dec 2024, at 23:51, Michail Nikolaev <michail.nikolaev@gmail.com> wrote:
>
> * Modify bt_index_parent_check to use an MVCC snapshot for the heap scan

Hi!

Interesting bug. It's amazing how long it stand, giving that it would be triggered by almost any check after updating a
table.

From my POV correct fix direction is to use approach similar to index building.
E.i. remove "if (!state->readonly)" check. Are there any known downsides of this?


Best regards, Andrey Borodin.


Re: bt_index_parent_check and concurrently build indexes

От
"Andrey M. Borodin"
Дата:

> On 13 Dec 2024, at 04:59, Michail Nikolaev <michail.nikolaev@gmail.com> wrote:
> <v3-0001-amcheck-Fix-bt_index_parent_check-behavior-with-C.patch>

+# Copyright (c) 2021-2024, PostgreSQL Global Development Group

I think usually write only commit year. Something tells me you can safely write 2025 there.

+Test::More->builder->todo_start('filesystem bug')
+  if PostgreSQL::Test::Utils::has_wal_read_bug;

Can't wrap my head why do you need this?

+# it fails, because it is expect to find the deleted row in index

I think this comment describes behavior before the fix in present tense.

-        if (snapshot != SnapshotAny)
-            UnregisterSnapshot(snapshot);

Snapshot business seems incorrect to me here...


Best regards, Andrey Borodin.


Re: bt_index_parent_check and concurrently build indexes

От
Donghang Lin
Дата:
Hi Michail 
 
> It turns out that bt_index_parent_check is not suitable for validating indexes built concurrently. 
Your finding is right on point! We recently used bt_index_parent_check to verify concurrently built indexes in a concurrent workload, bt_index_parent_check often gave such false positive error. 

- indexinfo->ii_Concurrent = !state->readonly;
+ indexinfo->ii_Concurrent = true;

One suggestion to this change is that we might need to update the amcheck doc to reflect that
"This consists of a “dummy” CREATE INDEX CONCURRENTLY operation" rather than "CREATE INDEX" operation.

Regards,
Donghang

Re: bt_index_parent_check and concurrently build indexes

От
Michael Paquier
Дата:
On Mon, Jun 02, 2025 at 05:40:18PM -0700, Donghang Lin wrote:
> Your finding is right on point! We recently used bt_index_parent_check to
> verify concurrently built indexes in a concurrent workload,
> bt_index_parent_check often gave such false positive error.

Good thing is that this is tracked in the CF app:
https://commitfest.postgresql.org/patch/5438/

Peter, could you look at that?  amcheck and btree are both in your
area of expertise.  Getting this error because of routine CIC or
REINDEX CONCURRENTLY runs is annoying.
--
Michael

Вложения

Re: bt_index_parent_check and concurrently build indexes

От
Mihail Nikalayeu
Дата:
Hello, Donghang!

> One suggestion to this change is that we might need to update the amcheck doc to reflect that
> "This consists of a “dummy” CREATE INDEX CONCURRENTLY operation" rather than "CREATE INDEX" operation.

+1, done. Also fixed some typos in the commit message.

Best regards,
Mikhail.

Вложения

Re: bt_index_parent_check and concurrently build indexes

От
Mihail Nikalayeu
Дата:
Hello, everyone!

Rebased.

Best regards,
Mikhail.

Вложения

Re: bt_index_parent_check and concurrently build indexes

От
Andrey Borodin
Дата:

> On 21 Jun 2025, at 21:10, Mihail Nikalayeu <mihailnikalayeu@gmail.com> wrote:
>
> Rebased

IMO the patch is RfC, I've just updated the status of the CF iteam.

Thanks.


Best regards, Andrey Borodin.


Re: bt_index_parent_check and concurrently build indexes

От
Mihail Nikalayeu
Дата:
Hello, everyone!

Could someone please take a look?

We have a confirmed bug, which happens in production [0], probably
needs to be backported and has a simple patch to address for about 9
months already....
I am not trying to blame someone, just to highlight how it sometimes
feels from the non-committer side.

Best regards,
Mikhail.

[0]:
https://www.postgresql.org/message-id/flat/CAA%3DD8a2Q23miHJtHRDk_TSQKvd6oHk8wGpkQt99B%3D9yd-oqnfg%40mail.gmail.com#e563629249821b5f61e44a635b758ad1