Re: Logical replication timeout problem
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, "wangw.fnst@fujitsu.com" <wangw.fnst@fujitsu.com>,
"shiy.fnst@fujitsu.com" <shiy.fnst@fujitsu.com>, "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>,
Peter Smith <smithpb2250@gmail.com>, Fabrice Chapuis <fabrice636861@gmail.com>, Euler Taveira <euler@eulerto.com>, Masahiko Sawada <sawada.mshk@gmail.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
Simon Riggs <simon.riggs@enterprisedb.com>, Petr Jelinek <petr.jelinek@enterprisedb.com>, "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Ajin Cherian <itsajin@gmail.com>
Date: 2023-02-08T08:06:02Z
Lists: pgsql-hackers
On Wed, Feb 8, 2023 at 10:57 AM Andres Freund <andres@anarazel.de> wrote: > > On 2023-02-03 10:13:54 +0530, Amit Kapila wrote: > > I am planning to push this to HEAD sometime next week (by Wednesday). > > To backpatch this, we need to fix it in some non-standard way, like > > without introducing a callback which I am not sure is a good idea. If > > some other committers vote to get this in back branches with that or > > some different idea that can be backpatched then we can do that > > separately as well. I don't see this as a must-fix in back branches > > because we have a workaround (increase timeout) or users can use the > > streaming option (for >=14). > > I just saw the commit go in, and a quick scan over it makes me think neither > this commit, nor f95d53eded, which unfortunately was already backpatched, is > the right direction. The wrong direction likely started quite a bit earlier, > with 024711bb544. > > It feels quite fundamentally wrong that bascially every output plugin needs to > call a special function in nearly every callback. > > In 024711bb544 there was just one call to OutputPluginUpdateProgress() in > pgoutput.c. Quite tellingly, it just updated pgoutput, without touching > test_decoding. > > Then a8fd13cab0b added to more calls. 63cf61cdeb7 yet another. > I think the original commit 024711bb544 forgets to call it in test_decoding and the other commits followed the same and missed to update test_decoding. > > This makes no sense. There's lots of output plugins out there. There's an > increasing number of callbacks. This isn't a maintainable path forward. > > > If we want to call something to maintain state, it has to be happening from > central infrastructure. > > > It feels quite odd architecturally that WalSndUpdateProgress() ends up > flushing out writes - that's far far from obvious. > > I don't think: > /* > * Wait until there is no pending write. Also process replies from the other > * side and check timeouts during that. > */ > static void > ProcessPendingWrites(void) > > Is really a good name. What are we processing? > It is for sending the keep_alive message (if required). That is normally done when we skipped processing a transaction to ensure sync replication is not delayed. It has been discussed previously [1][2] to extend the WalSndUpdateProgress() interface. Basically, as explained by Craig [2], this has to be done from plugin as it can do filtering or there could be other reasons why the output plugin skips all changes. We used the same interface for sending keep-alive message when we processed a lot of (DDL) changes without sending anything to plugin. [1] - https://www.postgresql.org/message-id/20200309183018.tzkzwu635sd366ej%40alap3.anarazel.de [2] - https://www.postgresql.org/message-id/CAMsr%2BYE3o8Dt890Q8wTooY2MpN0JvdHqUAHYL-LNhBryXOPaKg%40mail.gmail.com -- With Regards, Amit Kapila.
Commits
-
Fix the logical replication timeout during large DDLs.
- 8c58624df462 16.0 landed
-
Fix the logical replication timeout during large transactions.
- f95d53eded55 15.0 landed
- d6da71fa8f28 14.4 landed
- 55558df23741 13.8 landed
- f832b5007c1c 12.12 landed
- 87c1dd246af8 11.17 landed
- a4015ec0375d 10.22 landed
-
Rethink the delay-checkpoint-end mechanism in the back-branches.
- 10520f434687 14.3 cited
-
Revert "Logical decoding of sequences"
- 2c7ea57e56ca 15.0 cited
-
Skip empty transactions for logical replication.
- d5a9d86d8ffc 15.0 cited
-
Allow specifying column lists for logical replication
- 923def9a533a 15.0 cited
-
Add decoding of sequences to built-in replication
- 75b1521dae1f 15.0 cited
-
Fix ABI break introduced by commit 4daa140a2f.
- 56e366f6757d 13.4 cited
-
Lag tracking for logical replication
- 024711bb5446 10.0 cited