Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1na7UN-0007i5-03 for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Apr 2022 02:58:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1na7UL-0006bh-Qt for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Apr 2022 02:58:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1na7UK-0006bX-Ki for pgsql-hackers@lists.postgresql.org; Fri, 01 Apr 2022 02:58:13 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1na7UD-0003u3-Jc for pgsql-hackers@lists.postgresql.org; Fri, 01 Apr 2022 02:58:12 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 2E94B3201DBF; Thu, 31 Mar 2022 22:58:01 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute2.internal (MEProxy); Thu, 31 Mar 2022 22:58:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=ggRrzz8QpaQkmlUmD7wkiLD/xdm/rEVkmFCPo/ Zsfxo=; b=S85UV1hO4wctDg+4RmLbfsgenatFkDiInbeqOJl8nvZsScALJYjq8T Le7SG9ca9lrfKwq0w7B79ysFPveTIdeCfq3X4gvvLfxVSrlJFzDloHo1rCaxjZf0 mKQvdQmcPkSTqYSQqndOagkuHYOGJebqGppb30IAimUVlLLTXFxG28FqyZXM/1TV InIuAKMkZ9jlLejIVX4Z5d38fZDa8kigKS9Ei32k7YbIgt1dnBA3nu3LMPVQs5b2 QyEHpecCIiF5M29w7HgmBwJ1jwlI2DB7PqzYFWfYHa69iayvoY0cHxDsgZfalFLn ZW2qEKx8v88ABTqd3hanP6zXpOKePsfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=ggRrzz8QpaQkmlUmD 7wkiLD/xdm/rEVkmFCPo/Zsfxo=; b=NNIaWhnmYMyTygf1jcy+Ft4nKiWghy6ma /U5vqdWPIZIzJVe3QVqY5njVV3juMbdcFLYPBncHhpizNbK49FsctS9gh1L0vRz2 mYXBnvI1q6Xi80djfiOreLJk3jowRjoFcpETpPIskKxfCBhRL9gOvIb/LlwlHBpm 9hT/2Azp20c9zxyrNHNNfPnTVZQQWOAgqTwIDaUAA+4tDHEfQz+cn+hsqmEd4RCA SydibWndGGzxq25udC7uKCccTG89njrpJ8rc6szDUbGifyRHuPu10w/ZrUj3AAAh uevV9yHRR6jUQvPgPH0yiz3GH2zDLx/gTGuLyD6jIcKSVq30v00bw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeihedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesrgdtreerreertdenucfhrhhomhepfdfguhhl vghrucfvrghvvghirhgrfdcuoegvuhhlvghrsegvuhhlvghrthhordgtohhmqeenucggtf frrghtthgvrhhnpeejtefhuedvgffftdetvedufedtjeeuffekleevkefhveekgeelfefh jeehtdejgeenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepvghulhgvrhesvghu lhgvrhhtohdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 49CB7F6043A; Thu, 31 Mar 2022 22:58:00 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-382-g88b93171a9-fm-20220330.001-g88b93171 Mime-Version: 1.0 Message-Id: <8cc4f31f-240a-4590-94a8-a50bdf4f4d1c@www.fastmail.com> In-Reply-To: References: <0271e197-2cfe-4627-9c11-47535cc7fdf3@www.fastmail.com> Date: Thu, 31 Mar 2022 23:57:39 -0300 From: "Euler Taveira" To: "Amit Kapila" Cc: "Masahiko Sawada" , "wangw.fnst@fujitsu.com" , "kuroda.hayato@fujitsu.com" , "Peter Smith" , "Fabrice Chapuis" , "Simon Riggs" , "Petr Jelinek" , "tanghy.fnst@fujitsu.com" , "PostgreSQL Hackers" , "Ajin Cherian" Subject: Re: Logical replication timeout problem Content-Type: multipart/alternative; boundary=3351d8345bbe44c295507cd1a6481450 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3351d8345bbe44c295507cd1a6481450 Content-Type: text/plain On Thu, Mar 31, 2022, at 11:27 PM, Amit Kapila wrote: > This is exactly our initial analysis and we have tried a patch on > these lines and it has a noticeable overhead. See [1]. Calling this > for each change or each skipped change can bring noticeable overhead > that is why we decided to call it after a certain threshold (100) of > skipped changes. Now, surely as mentioned in my previous reply we can > make it generic such that instead of calling this (update_progress > function as in the patch) for skipped cases, we call it always. Will > that make it better? That's what I have in mind but using a different approach. > > The functions CreateInitDecodingContext and CreateDecodingContext receives the > > update_progress function as a parameter. These functions are called in 2 > > places: (a) streaming replication protocol (CREATE_REPLICATION_SLOT) and (b) > > SQL logical decoding functions (pg_logical_*_changes). Case (a) uses > > WalSndUpdateProgress as a progress function. Case (b) does not have one because > > it is not required -- local decoding/communication. There is no custom update > > progress routine for each output plugin which leads me to the question: > > couldn't we encapsulate the update progress call into the callback functions? > > > > Sorry, I don't get your point. What exactly do you mean by this? > AFAIS, currently we call this output plugin API in pgoutput functions > only, do you intend to get it invoked from a different place? It seems I didn't make myself clear. The callbacks I'm referring to the *_cb_wrapper functions. After every ctx->callbacks.foo_cb() call into a *_cb_wrapper() function, we have something like: if (ctx->progress & PGOUTPUT_PROGRESS_FOO) NewUpdateProgress(ctx, false); The NewUpdateProgress function would contain a logic similar to the update_progress() from the proposed patch. (A different function name here just to avoid confusion.) The output plugin is responsible to set ctx->progress with the callback variables (for example, PGOUTPUT_PROGRESS_CHANGE for change_cb()) that we would like to run NewUpdateProgress. -- Euler Taveira EDB https://www.enterprisedb.com/ --3351d8345bbe44c295507cd1a6481450 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Thu, Mar 31,= 2022, at 11:27 PM, Amit Kapila wrote:
This is exactly our initial analysis and we = have tried a patch on
these lines and it has a noticeable = overhead. See [1]. Calling this
for each change or each sk= ipped change can bring noticeable overhead
that is why we = decided to call it after a certain threshold (100) of
skip= ped changes. Now, surely as mentioned in my previous reply we can
make it generic such that instead of calling this (update_progre= ss
function as in the patch) for skipped cases, we call it= always. Will
that make it better?
<= div>That's what I have in mind but using a different approach.
=

> = The functions CreateInitDecodingContext and CreateDecodingContext receiv= es the
> update_progress function as a parameter. These= functions are called in 2
> places: (a) streaming repl= ication protocol (CREATE_REPLICATION_SLOT) and (b)
> SQ= L logical decoding functions (pg_logical_*_changes). Case (a) uses
> WalSndUpdateProgress as a progress function. Case (b) does= not have one because
> it is not required -- local dec= oding/communication. There is no custom update
> progre= ss routine for each output plugin which leads me to the question:
> couldn't we encapsulate the update progress call into the c= allback functions?
>

Sorry= , I don't get your point. What exactly do you mean by this?
AFAIS, currently we call this output plugin API in pgoutput functions<= br>
only, do you intend to get it invoked from a different pla= ce?
It seems I didn't make myself clear. The = callbacks I'm referring to the
*_cb_wrapper functions. Aft= er every ctx->callbacks.foo_cb() call into a
*_cb_wrapp= er() function, we have something like:

if (= ctx->progress & PGOUTPUT_PROGRESS_FOO)
  =   NewUpdateProgress(ctx, false);

The N= ewUpdateProgress function would contain a logic similar to the
=
update_progress() from the proposed patch. (A different function na= me here just
to avoid confusion.)

=
The output plugin is responsible to set ctx->progress with the c= allback
variables (for example, PGOUTPUT_PROGRESS_CHANGE f= or change_cb()) that we would
like to run NewUpdateProgres= s.


--
Euler Taveira

--3351d8345bbe44c295507cd1a6481450--