Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Date: 2021-08-07 15:33:18
Message-ID: DBD361BB-4327-4143-A849-36A262B22CEE@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> 6 авг. 2021 г., в 23:03, Andrey Borodin <x4mmm(at)yandex-team(dot)ru> написал(а):
>
> But how to get why something did not happen?
> During GetLockConflicts() proclocks SHMQueue do not include locks of concurrently running xid within PrepareTransaction() [seems like it's with PostPrepare_locks(), but I'm not sure].
> The problem is reproducible within 1 second by the script leading to amcheck-detected corruption.

Ok, finally I've figured out this charade.

AtPrepare_Locks() transfers fast-path locks to normal locks pointing to PGPROC with xid in a process of conversion to 2PC.
ProcArrayClearTransaction(MyProc) resets xid int PGROCs.
GetLockConflicts() sees empty xid and vxid.
PostPrepare_Locks(xid) hids things with new PGPROC for 2PC.

PFA PoC fix. But I'm entirely not sure it's OK to do reorder things at PrepareTransaction() this way.

Thanks!

Best regards, Andrey Borodin.

Attachment Content-Type Size
v9-0001-Introduce-TAP-test-for-2PC-with-CIC-behavior.patch application/octet-stream 7.0 KB
v9-0004-PoC-fix-clear-xid.patch application/octet-stream 1.0 KB
v9-0003-Fix-CREATE-INDEX-CONCURRENTLY-in-precence-of-vxid.patch application/octet-stream 8.5 KB
v9-0002-PoC-fix-for-race-in-RelationBuildDesc-and-relcach.patch application/octet-stream 2.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Borodin 2021-08-07 19:00:55 Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Previous Message Julien Rouhaud 2021-08-07 06:37:55 Re: BUG #17136: set shared_preload_libraries = 'pg_stat_statements,pg_prewarm,pg_trgm' , postgresql Cannot Startup