Subject: RE: Parallel Apply

From: "Hayato Kuroda (Fujitsu)" <[email-masked]>
Date: Mon, 5 Jan 2026 07:40:45 +0000

Happy new year hackers,

I found that CFbot sometimes failed tests. Per my analysis, there were two
issues in the 0005 patch. The following describes two changes.

1)
Took care of the case where an empty prepared transaction was replicated.
The leader worker would gather even such transactions in get_flush_position()
and try to clean up a replica identity hash. If the empty transaction is firstly
replicated after the worker is launched, however, the replica identity hash is
not yet initialized, which causes the segmentation fault. To address the issue,
a guard was added to the cleanup function.

As far as I know, an empty prepared transaction can happen if
  a) the prepared transaction has already been rolled back while decoding, or
  b) all changes are skipped.
Added test sometimes meets a) due to the timing issue.

2)
Fixed a timing issue in 050_parallel_apply.pl. The test sets the two_phase
option to true, but sometimes it fails if the apply workers are not yet finished
after the subscription is disabled. Now the test ensures there are no apply workers.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

---

From: "Hayato Kuroda (Fujitsu)" <[email-masked]>
Date: Fri, 30 Jan 2026 11:18:07 +0000

Dear Hackers,

Here is a rebased version, plus 0009 patch.

0009 contains changes to handle dependencies based on the foreign keys. Without
this, parallel apply can violate foreign key constraints if referenced tuples
are committed after referencing tuples, leading to replication failures.

This patch extends the dependency hash to track dependencies via FKs. Since
referenced columns must be unique, information must be already stored to the
hash if they have been modified. Based on the point, the leader apply worker
checks to determine whether values in referencing columns have already been
registered or not if applying tuples refer some columns, and regards that there
is a dependency if found.

Best regards,
Hayato Kuroda
FUJITSU LIMITED