Re: Parallel Apply

From: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Parallel Apply
Date: 2025-09-17 06:28:53
Message-ID: 932469d2-58b5-47a1-921c-33c7fd453e23@garret.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 17/09/2025 8:18 AM, Zhijie Hou (Fujitsu) wrote:
> I think debug_logical_replication_streaming=immediate differs from real parallel
> apply . It wasn't designed to simulate genuine parallel application because it
> restricts parallelism by requiring the leader to wait for each transaction to
> complete on commit. To achieve in-order parallel apply, each parallel apply
> worker should wait for the preceding transaction to finish, similar to the
> dependency wait in the current POC patch. We plan to extend the patch to support
> in-order parallel apply and will test its performance.

Will be interesting to see such results.
Actually, I have tried to improve parallelism in case of `debug_log And
debug_logical_replication_streaming=immediate` mode but faced with
deadlock issue: assume that T1 and T2 are updating the same tuples and
T1 is committed before T2 at publishers. If we let them execute in
parallel, then T2 can update the tuple first and T1 will wait end of T2.
But if we want to preserve commit order, we should not allow T2 to
commit before T1. And so we will get deadlock.

Certainly if we take in account dependencies between transactions (as in
your proposal), then we can avoid such situations. But I am not sure if
such deadlock can not happen even if there are conflicts between
transactions. Let's assume that T1 and T2 inserting some new records in
one table. Can index update in T2 cause obtaining some locks which
blocks T1? And T2 is not able to able to complete transaction and
release this locks because we want to commit T1 first.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2025-09-17 06:28:57 Re: Make TID Scans recalculate the TIDs less often
Previous Message Amit Kapila 2025-09-17 06:19:20 Re: [Patch] add new parameter to pg_replication_origin_session_setup