Re: Perform streaming logical transactions by background workers and parallel apply

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, "wangw(dot)fnst(at)fujitsu(dot)com" <wangw(dot)fnst(at)fujitsu(dot)com>, "shiy(dot)fnst(at)fujitsu(dot)com" <shiy(dot)fnst(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Perform streaming logical transactions by background workers and parallel apply
Date: 2022-12-26 14:05:24
Message-ID: CAFiTN-vfUFAzrgMQixQ7rKHXYL+2xbPR_8OVVX0zkiGWC2M+aQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 26, 2022 at 6:59 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>

In the commit message, there is a statement like this

"However, if the leader apply worker times out while attempting to
send a message to the
parallel apply worker, it will switch to "partial serialize" mode - in this
mode the leader serializes all remaining changes to a file and notifies the
parallel apply workers to read and apply them at the end of the transaction."

I think it is a good idea to serialize the change to the file in this
case to avoid deadlocks, but why does the parallel worker need to wait
till the transaction commits to reading the file? I mean we can
switch the serialize state and make a parallel worker pull changes
from the file and if the parallel worker has caught up with the
changes then it can again change the state to "share memory" and now
the apply worker can again start sending through shared memory.

I think generally streaming transactions are large and it is possible
that the shared memory queue gets full because of a lot of changes for
a particular transaction but later when the load switches to the other
transactions then it would be quite common for the worker to catch up
with the changes then it better to again take advantage of using
memory. Otherwise, in this case, we are just wasting resources
(worker/shared memory queue) but still writing in the file.

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2022-12-26 14:07:00 Re: Time delayed LR (WAS Re: logical replication restrictions)
Previous Message Andrew Dunstan 2022-12-26 13:59:08 Re: Error-safe user functions