Re: BUG #17268: Possible corruption in toast index after reindex index concurrently

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Alexey Ermakov <alexey(dot)ermakov(at)dataegret(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: BUG #17268: Possible corruption in toast index after reindex index concurrently
Date: 2021-12-06 01:53:45
Message-ID: Ya1tKYLozbcvw5Dw@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Nov 15, 2021 at 08:03:04PM +0900, Michael Paquier wrote:
> After more testing, I have been able to extract and write an isolation
> test that is able to reproduce the failure. It relies on a trick as
> the toast relation names are not deterministic, and we cannot use
> REINDEX CONCURRENTLY in a function context. So I have used an ALTER
> TABLE/INDEX RENAME with a DO block to change the toast relation
> names with allow_system_table_mods instead. There is no need either
> for amcheck with this method.
>
> 2) is enough to fix the problem, and I'd like to think that we had
> better stick with only this method for simplicity's sake.

I have been working on this one again for the last couple of days, and
I would still go with the simple solution, releasing the row-level
toast locks only at the end of the transaction when saving and
deleting a toast value. While testing, I have noticed that the
deletion part is also important, as a REINDEX CONCURRENTLY run in
parallel of a transaction removing a toast value would go through
without that, rather than waiting for the transaction doing the
deletion to commit first. I have expanded the tests with everything I
could think about, so I'd like to commit the attached. The test is
fancy with its use of allow_system_table_mods to make the toast
relation names reliable, but it has been really useful.
--
Michael

Attachment Content-Type Size
v2-0001-Fix-locking-of-toast-relations-with-REINDEX-CONC.patch text/x-diff 35.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-12-06 06:40:39 BUG #17318: ERROR: AddressSanitizer: SEGV on unknown address in optimizer
Previous Message Tom Lane 2021-12-05 16:10:29 Re: BUG #17315: Postgresql needs reinstall after restore