RE: Slow catchup of 2PC (twophase) transactions on replica in LR
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Vitaly Davydov' <v.davydov@postgrespro.ru>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Ajin Cherian <itsajin@gmail.com>, Heikki Linnakangas <hlinnaka@iki.fi>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2024-07-08T07:04:40Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix random failure in 021_twophase.
- 0dcea330babd 18.0 landed
-
Allow altering of two_phase option of a SUBSCRIPTION.
- 1462aad2e447 18.0 landed
-
Doc: use true|false rather than on|off for "failover" option
- fa65a022db26 17.0 cited
-
Support an optional asynchronous commit mode, in which we don't flush WAL
- 4a78cdeb6b59 8.3.0 cited
Attachments
- v16-0001-Allow-altering-of-two_phase-option-of-a-SUBSCRIP.patch (application/octet-stream) patch v16-0001
- v16-0002-Alter-slot-option-two_phase-only-when-altering-t.patch (application/octet-stream) patch v16-0002
- v16-0003-Abort-prepared-transactions-while-altering-two_p.patch (application/octet-stream) patch v16-0003
- v16-0004-Add-force_alter-option-for-ALTER-SUBSCRIPTION-.-.patch (application/octet-stream) patch v16-0004
Dear Vitaly, Thanks for giving comments! PSA new version patch. > Thank you very much for the patch. In general, it seem to work well for me, but > there seems to be a memory access problem in libpqrcv_alter_slot -> > quote_identifier in case of NULL slot_name. It happens, if the two_phase option > is altered on a subscription without slot. I think, a simple check for NULL may > fix the problem. I guess, the same problem may be for failover option. You are right. Regarding the failover option, it requires that slot_name is valid. In case of two_phase, we must connect to the publisher only when altering "true" to "false", slot_name must be there only at that time. Updated. > Another possible problem is related to my use case. I haven't reproduced this > case, just some thoughts. I guess, when two_phase is ON, the PREPARE statement > may be truncated from the WAL at checkpoint, but COMMIT PREPARED is still kept > in the WAL. On catchup, I would ask the master to send transactions from some > restart LSN. I would like to get all such transactions competely, with theirs > bodies, not only COMMIT PREPARED messages. I don't think it is a real issue. WALs for prepared transactions will retain until they are committed/aborted. When the two_phase is on and transactions are PREPAREd, they will not be cleaned up from the memory (See ReorderBufferProcessTXN()). Then, RUNNING_XACT record leads to update the restart_lsn of the slot but it cannot be move forward because ReorderBufferGetOldestTXN() returns the prepared transaction (See SnapBuildProcessRunningXacts()). restart_decoding_lsn of each transaction, which is a candidate of restart_lsn of the slot. is always behind the startpoint of its txn. Best Regards, Hayato Kuroda FUJITSU LIMITED https://www.fujitsu.com/global/