Re: Minimal logical decoding on standbys

2023-04-11 Thread Noah Misch
On Tue, Apr 11, 2023 at 01:10:57PM -0700, Andres Freund wrote: > On 2023-04-11 11:04:50 +0200, Drouvot, Bertrand wrote: > > On 4/11/23 10:55 AM, Drouvot, Bertrand wrote: > > > I think we might want to add: > > > > > > $node_primary->wait_for_replay_catchup($node_standby); > > > > > > before

Re: Minimal logical decoding on standbys

2023-04-11 Thread Tom Lane
Andres Freund writes: > I think we should lower the log level, but perhaps wait for a few more cycles > in case there are random failures? Removing -log_min_messages = 'debug2' -log_error_verbosity = verbose not only reduces 035's log output volume from 1.6MB to 260kB, but also speeds it up

Re: Minimal logical decoding on standbys

2023-04-11 Thread Andres Freund
Hi, On 2023-04-11 11:04:50 +0200, Drouvot, Bertrand wrote: > On 4/11/23 10:55 AM, Drouvot, Bertrand wrote: > > Hi, > > > > I think we might want to add: > > > > $node_primary->wait_for_replay_catchup($node_standby); > > > > before calling the slot creation. > > > > It's done in the attached,

Re: Minimal logical decoding on standbys

2023-04-11 Thread Drouvot, Bertrand
Hi, On 4/11/23 10:55 AM, Drouvot, Bertrand wrote: Hi, I think we might want to add: $node_primary->wait_for_replay_catchup($node_standby); before calling the slot creation. It's done in the attached, would it be possible to give it a try please? Actually, let's also wait for the cascading

Re: Minimal logical decoding on standbys

2023-04-11 Thread Drouvot, Bertrand
Hi, On 4/11/23 10:20 AM, Drouvot, Bertrand wrote: Hi, On 4/11/23 7:36 AM, Noah Misch wrote: On Fri, Apr 07, 2023 at 11:12:26AM -0700, Andres Freund wrote: --- /dev/null +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -0,0 +1,720 @@ +# logical decoding on standby : test logical

Re: Minimal logical decoding on standbys

2023-04-11 Thread Drouvot, Bertrand
Hi, On 4/11/23 7:36 AM, Noah Misch wrote: On Fri, Apr 07, 2023 at 11:12:26AM -0700, Andres Freund wrote: --- /dev/null +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -0,0 +1,720 @@ +# logical decoding on standby : test logical decoding, +# recovery conflict and standby promotion.

Re: Minimal logical decoding on standbys

2023-04-10 Thread Noah Misch
On Fri, Apr 07, 2023 at 11:12:26AM -0700, Andres Freund wrote: > --- /dev/null > +++ b/src/test/recovery/t/035_standby_logical_decoding.pl > @@ -0,0 +1,720 @@ > +# logical decoding on standby : test logical decoding, > +# recovery conflict and standby promotion. ... >

Re: Minimal logical decoding on standbys

2023-04-08 Thread Jonathan S. Katz
On 4/8/23 5:27 AM, Andres Freund wrote: Hi, On 2023-04-07 14:27:09 -0700, Andres Freund wrote: I think I'll push these in a few hours. While this needed more changes than I'd like shortly before the freeze, I think they're largely not in very interesting bits and pieces - and this feature has

Re: Minimal logical decoding on standbys

2023-04-08 Thread Andres Freund
Hi, On 2023-04-07 14:27:09 -0700, Andres Freund wrote: > I think I'll push these in a few hours. While this needed more changes than > I'd like shortly before the freeze, I think they're largely not in very > interesting bits and pieces - and this feature has been in the works for about > three

Re: Minimal logical decoding on standbys

2023-04-08 Thread Bertrand Drouvot
Hi, New wording works for me, thanks! Bertrand Le sam. 8 avr. 2023, 08:26, Andres Freund a écrit : > Hi, > > On 2023-04-07 11:12:26 -0700, Andres Freund wrote: > > + > > + > > + confl_active_logicalslot > bigint > > + > > + > > + Number of active logical

Re: Minimal logical decoding on standbys

2023-04-08 Thread Andres Freund
Hi, On 2023-04-07 11:12:26 -0700, Andres Freund wrote: > + > + > + confl_active_logicalslot > bigint > + > + > + Number of active logical slots in this database that have been > + invalidated because they conflict with recovery (note that inactive > ones

Re: Minimal logical decoding on standbys

2023-04-07 Thread Amit Kapila
On Sat, Apr 8, 2023 at 9:31 AM Andres Freund wrote: > > On 2023-04-08 09:15:05 +0530, Amit Kapila wrote: > > The new approach for invalidation looks clean. BTW, I see minor > > inconsistency in the following two error messages (errmsg): > > Thanks for checking. > > > > if

Re: Minimal logical decoding on standbys

2023-04-07 Thread Jonathan S. Katz
On 4/8/23 12:01 AM, Andres Freund wrote: Hi, On 2023-04-08 09:15:05 +0530, Amit Kapila wrote: The new approach for invalidation looks clean. BTW, I see minor inconsistency in the following two error messages (errmsg): Thanks for checking. if (MyReplicationSlot->data.invalidated ==

Re: Minimal logical decoding on standbys

2023-04-07 Thread Andres Freund
Hi, On 2023-04-08 09:15:05 +0530, Amit Kapila wrote: > The new approach for invalidation looks clean. BTW, I see minor > inconsistency in the following two error messages (errmsg): Thanks for checking. > if (MyReplicationSlot->data.invalidated == RS_INVAL_WAL) > ereport(ERROR, >

Re: Minimal logical decoding on standbys

2023-04-07 Thread Amit Kapila
On Fri, Apr 7, 2023 at 11:42 PM Andres Freund wrote: > > On 2023-04-07 08:47:57 -0700, Andres Freund wrote: > > Integrated all of these. > > Here's my current version. Changes: > - Integrated Bertrand's changes > - polished commit messages of 0001-0003 > - edited code comments for 0003, including

Re: Minimal logical decoding on standbys

2023-04-07 Thread Andres Freund
Hi, On 2023-04-07 18:32:04 -0400, Melanie Plageman wrote: > Code review only of 0001-0005. > > I noticed you had two 0008, btw. Yea, sorry for that. One was the older version. Just before sending the patch I saw another occurance of a test failure, which I then fixed. In the course of that I

Re: Minimal logical decoding on standbys

2023-04-07 Thread Melanie Plageman
Code review only of 0001-0005. I noticed you had two 0008, btw. On Fri, Apr 07, 2023 at 11:12:26AM -0700, Andres Freund wrote: > Hi, > > On 2023-04-07 08:47:57 -0700, Andres Freund wrote: > > Integrated all of these. > > From 0e038eb5dfddec500fbf4625775d1fa508a208f6 Mon Sep 17 00:00:00 2001 >

Re: Minimal logical decoding on standbys

2023-04-07 Thread Alvaro Herrera
I gave a very quick look at 0001 and 0003. I find no fault with 0001. It was clear back when we added that stuff that invalidated_at was not terribly useful -- I was just too conservative to not have it -- but now that a lot of time has passed and we haven't done anything with it, removing it

Re: Minimal logical decoding on standbys

2023-04-07 Thread Andres Freund
Hi, On 2023-04-07 22:54:01 +0200, Drouvot, Bertrand wrote: > That looks good to me Cool. I think I'll push these in a few hours. While this needed more changes than I'd like shortly before the freeze, I think they're largely not in very interesting bits and pieces - and this feature has been in

Re: Minimal logical decoding on standbys

2023-04-07 Thread Drouvot, Bertrand
Hi, On 4/7/23 8:24 PM, Drouvot, Bertrand wrote: Hi, On 4/7/23 5:47 PM, Andres Freund wrote: Hi, - write a test that invalidated logical slots do not lead to retaining WAL I'm not sure how to do that since pg_switch_wal() and friends can't be executed on a standby. You can do it on the

Re: Minimal logical decoding on standbys

2023-04-07 Thread Drouvot, Bertrand
Hi, On 4/7/23 8:27 PM, Drouvot, Bertrand wrote: Hi, I think some of the patches might have more reviewers than really applicable, and might also miss some. I'd appreciate if you could go over that... Sure, will do in a couple of hours. That looks good to me, just few remarks: 0005 is

Re: Minimal logical decoding on standbys

2023-04-07 Thread Drouvot, Bertrand
Hi, On 4/7/23 8:12 PM, Andres Freund wrote: Hi, On 2023-04-07 08:47:57 -0700, Andres Freund wrote: Integrated all of these. Here's my current version. Changes: - Integrated Bertrand's changes - polished commit messages of 0001-0003 - edited code comments for 0003, including

Re: Minimal logical decoding on standbys

2023-04-07 Thread Drouvot, Bertrand
Hi, On 4/7/23 5:47 PM, Andres Freund wrote: Hi, - write a test that invalidated logical slots do not lead to retaining WAL I'm not sure how to do that since pg_switch_wal() and friends can't be executed on a standby. You can do it on the primary and wait for the records to have been

Re: Minimal logical decoding on standbys

2023-04-07 Thread Andres Freund
Hi, On 2023-04-07 08:47:57 -0700, Andres Freund wrote: > Integrated all of these. Here's my current version. Changes: - Integrated Bertrand's changes - polished commit messages of 0001-0003 - edited code comments for 0003, including InvalidateObsoleteReplicationSlots()'s header - added a bump

Re: Minimal logical decoding on standbys

2023-04-07 Thread Andres Freund
Hi, On 2023-04-07 17:13:13 +0200, Drouvot, Bertrand wrote: > On 4/7/23 9:50 AM, Andres Freund wrote: > > I added a check for !invalidated to > > ReplicationSlotsComputeRequiredLSN() etc. > > > > looked at 65-0001 and it looks good to me. > > > Added new patch moving checks for invalid logical

Re: Minimal logical decoding on standbys

2023-04-07 Thread Drouvot, Bertrand
Hi, On 4/7/23 9:50 AM, Andres Freund wrote: Hi, Here's my current working state - I'll go to bed soon. Thanks a lot for this Andres! Changes: - shared catalog relations weren't handled correctly, because the dboid is InvalidOid for them. I wrote a test for that as well. -

Re: Minimal logical decoding on standbys

2023-04-07 Thread Andres Freund
Hi, On 2023-04-07 08:09:50 +0200, Drouvot, Bertrand wrote: > Hi, > > On 4/7/23 7:56 AM, Andres Freund wrote: > > Hi, > > > > On 2023-04-07 07:02:04 +0200, Drouvot, Bertrand wrote: > > > Done in V63 attached and did change the associated comment a bit. > > > > Can you send your changes

Re: Minimal logical decoding on standbys

2023-04-07 Thread Drouvot, Bertrand
Hi, On 4/7/23 7:56 AM, Andres Freund wrote: Hi, On 2023-04-07 07:02:04 +0200, Drouvot, Bertrand wrote: Done in V63 attached and did change the associated comment a bit. Can you send your changes incrementally, relative to V62? I'm polishing them right now, and that'd make it a lot easier to

Re: Minimal logical decoding on standbys

2023-04-06 Thread Andres Freund
Hi, On 2023-04-07 07:02:04 +0200, Drouvot, Bertrand wrote: > Done in V63 attached and did change the associated comment a bit. Can you send your changes incrementally, relative to V62? I'm polishing them right now, and that'd make it a lot easier to apply your changes ontop. Greetings, Andres

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/7/23 5:47 AM, Amit Kapila wrote: On Thu, Apr 6, 2023 at 7:50 PM Drouvot, Bertrand wrote: Thanks! Will update 0005. I noticed a few typos in the latest patches. 0004 1. + * Physical walsenders don't need to be wakon up during replay unless Typo. Thanks! Fixed in V63 just

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/6/23 4:20 PM, Drouvot, Bertrand wrote: Hi, On 4/6/23 3:39 PM, Amit Kapila wrote: On Thu, Apr 6, 2023 at 6:32 PM Drouvot, Bertrand wrote: I don't think it could be possible to create logical walsenders on a standby if AllowCascadeReplication() is not true, or am I missing

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/7/23 4:18 AM, Andres Freund wrote: Hi, TBH, I don't like the state of 0001 much. I'm working on polishing it now. Thanks Andres! A lot of the new functions in slot.h don't seem right to me: - ObsoleteSlotIsInvalid() - isn't an obsolete slot by definition invalid? bad naming,

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
On 4/7/23 3:59 AM, Amit Kapila wrote: On Fri, Apr 7, 2023 at 6:55 AM Andres Freund wrote: On 2023-04-06 12:10:57 +0530, Amit Kapila wrote: After this, I think for backends that have active slots, it would simply cancel the current query. Will that be sufficient? Because we want the backend

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Thu, Apr 6, 2023 at 7:50 PM Drouvot, Bertrand wrote: > > Thanks! Will update 0005. > I noticed a few typos in the latest patches. 0004 1. + * Physical walsenders don't need to be wakon up during replay unless Typo. 0005 2. +# Check if all the slots on standby are dropped. These include the

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Fri, Apr 7, 2023 at 8:43 AM Andres Freund wrote: > > On 2023-04-06 12:10:57 +0530, Amit Kapila wrote: > > Also, it seems you have removed the checks related to > > slots, is it because PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT is only > > used for logical slots? If so, do you think an Assert would

Re: Minimal logical decoding on standbys

2023-04-06 Thread Andres Freund
Hi, On 2023-04-06 12:10:57 +0530, Amit Kapila wrote: > Also, it seems you have removed the checks related to > slots, is it because PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT is only > used for logical slots? If so, do you think an Assert would make > sense? The asserts that have been added aren't

Re: Minimal logical decoding on standbys

2023-04-06 Thread Andres Freund
Hi, TBH, I don't like the state of 0001 much. I'm working on polishing it now. A lot of the new functions in slot.h don't seem right to me: - ObsoleteSlotIsInvalid() - isn't an obsolete slot by definition invalid? - Why does ObsoleteSlotIsInvalid() sometime check invalidated_at and sometimes

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Fri, Apr 7, 2023 at 6:55 AM Andres Freund wrote: > > On 2023-04-06 12:10:57 +0530, Amit Kapila wrote: > > After this, I think for backends that have active slots, it would > > simply cancel the current query. Will that be sufficient? Because we > > want the backend process should exit and

Re: Minimal logical decoding on standbys

2023-04-06 Thread Andres Freund
Hi, On 2023-04-06 12:10:57 +0530, Amit Kapila wrote: > After this, I think for backends that have active slots, it would > simply cancel the current query. Will that be sufficient? Because we > want the backend process should exit and release the slot so that the > startup process can mark it

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/6/23 3:39 PM, Amit Kapila wrote: On Thu, Apr 6, 2023 at 6:32 PM Drouvot, Bertrand wrote: I don't think it could be possible to create logical walsenders on a standby if AllowCascadeReplication() is not true, or am I missing something? Right, so why to even traverse walsenders

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Thu, Apr 6, 2023 at 6:32 PM Drouvot, Bertrand wrote: > > Hi, > > On 4/6/23 11:55 AM, Amit Kapila wrote: > > On Thu, Apr 6, 2023 at 12:10 PM Amit Kapila wrote: > >> > >> On Wed, Apr 5, 2023 at 9:27 PM Drouvot, Bertrand > >> wrote: > >>> > >> > >> Another comment on 0001. > >> extern void

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/6/23 2:23 PM, Amit Kapila wrote: On Thu, Apr 6, 2023 at 11:29 AM Amit Kapila wrote: Thinking some more on this, I think such a slot won't decode any other records. During CreateInitDecodingContext->ReplicationSlotReserveWal, for standby's, we use lastReplayedEndRecPtr as restart_lsn.

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/6/23 7:59 AM, Amit Kapila wrote: On Wed, Apr 5, 2023 at 6:14 PM Drouvot, Bertrand wrote: On 4/5/23 12:28 PM, Amit Kapila wrote: On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand wrote: Maybe we could change the doc with something among those lines instead? " Existing logical

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/6/23 11:55 AM, Amit Kapila wrote: On Thu, Apr 6, 2023 at 12:10 PM Amit Kapila wrote: On Wed, Apr 5, 2023 at 9:27 PM Drouvot, Bertrand wrote: Another comment on 0001. extern void CheckSlotRequirements(void); extern void CheckSlotPermissions(void); +extern void

Re: Minimal logical decoding on standbys

2023-04-06 Thread Drouvot, Bertrand
Hi, On 4/6/23 8:40 AM, Amit Kapila wrote: On Wed, Apr 5, 2023 at 9:27 PM Drouvot, Bertrand After this, I think for backends that have active slots, it would simply cancel the current query. Will that be sufficient? Because we want the backend process should exit and release the slot so that

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Thu, Apr 6, 2023 at 11:29 AM Amit Kapila wrote: > > > > > This doesn't seem to be addressed in the latest version. And today, I > think I see one more point about this doc change: > + > + A logical replication slot can also be created on a hot standby. > To prevent > + VACUUM from

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Thu, Apr 6, 2023 at 12:10 PM Amit Kapila wrote: > > On Wed, Apr 5, 2023 at 9:27 PM Drouvot, Bertrand > wrote: > > > > Another comment on 0001. > extern void CheckSlotRequirements(void); > extern void CheckSlotPermissions(void); > +extern void ResolveRecoveryConflictWithLogicalSlots(Oid

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Wed, Apr 5, 2023 at 9:27 PM Drouvot, Bertrand wrote: > > On 4/5/23 3:15 PM, Amit Kapila wrote: > > On Wed, Apr 5, 2023 at 6:14 PM Drouvot, Bertrand > > wrote: > >> > >> On 4/5/23 12:28 PM, Amit Kapila wrote: > >>> On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand > >>> wrote: > >> > >>> minor

Re: Minimal logical decoding on standbys

2023-04-06 Thread Amit Kapila
On Wed, Apr 5, 2023 at 6:14 PM Drouvot, Bertrand wrote: > > On 4/5/23 12:28 PM, Amit Kapila wrote: > > On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand > > wrote: > >> Maybe we could change the doc with something among those lines instead? > >> > >> " > >> Existing logical slots on standby also

Re: Minimal logical decoding on standbys

2023-04-05 Thread Andres Freund
Hi, On 2023-04-05 17:56:14 +0200, Drouvot, Bertrand wrote: > @@ -7963,6 +7963,23 @@ xlog_redo(XLogReaderState *record) > /* Update our copy of the parameters in pg_control */ > memcpy(, XLogRecGetData(record), > sizeof(xl_parameter_change)); > > + /* > +

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/5/23 4:24 PM, Robert Haas wrote: On Tue, Apr 4, 2023 at 8:33 PM Jeff Davis wrote: For comments, I agree that WalSndWakeup() clearly needs a comment update. The call site in ApplyWalRecord() could also use a comment. You could add a comment at every call site, but I don't think that's

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/5/23 3:15 PM, Amit Kapila wrote: On Wed, Apr 5, 2023 at 6:14 PM Drouvot, Bertrand wrote: On 4/5/23 12:28 PM, Amit Kapila wrote: On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand wrote: minor nitpick: + + /* Intentional fall through to session cancel */ + /* FALLTHROUGH */ Do we

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/5/23 1:59 PM, Amit Kapila wrote: On Wed, Apr 5, 2023 at 3:58 PM Amit Kapila wrote: On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand wrote: minor nitpick: + + /* Intentional fall through to session cancel */ + /* FALLTHROUGH */ Do we need to repeat fall through twice in different

Re: Minimal logical decoding on standbys

2023-04-05 Thread Robert Haas
On Tue, Apr 4, 2023 at 8:33 PM Jeff Davis wrote: > Perhaps a commit message like: > > "For cascading replication, wake up physical walsenders separately from > logical walsenders. > > Physical walsenders can't send data until it's been flushed; logical > walsenders can't decode and send data

Re: Minimal logical decoding on standbys

2023-04-05 Thread Amit Kapila
On Wed, Apr 5, 2023 at 6:14 PM Drouvot, Bertrand wrote: > > On 4/5/23 12:28 PM, Amit Kapila wrote: > > On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand > > wrote: > > > minor nitpick: > > + > > + /* Intentional fall through to session cancel */ > > + /* FALLTHROUGH */ > > > > Do we need to

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/5/23 12:28 PM, Amit Kapila wrote: On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand wrote: Maybe we could change the doc with something among those lines instead? " Existing logical slots on standby also get invalidated if wal_level on primary is reduced to less than 'logical'. This

Re: Minimal logical decoding on standbys

2023-04-05 Thread Amit Kapila
On Wed, Apr 5, 2023 at 3:58 PM Amit Kapila wrote: > > On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand > wrote: > > minor nitpick: > + > + /* Intentional fall through to session cancel */ > + /* FALLTHROUGH */ > > Do we need to repeat fall through twice in different ways? > Few minor comments

Re: Minimal logical decoding on standbys

2023-04-05 Thread Amit Kapila
On Wed, Apr 5, 2023 at 2:41 PM Drouvot, Bertrand wrote: > > On 4/5/23 8:59 AM, Amit Kapila wrote: > > On Mon, Apr 3, 2023 at 12:05 PM Amit Kapila wrote: > > > On further thinking, as such this shouldn't be a problem because all > > the WAL records before PARAMETER_CHANGE record will have

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/5/23 8:59 AM, Amit Kapila wrote: On Mon, Apr 3, 2023 at 12:05 PM Amit Kapila wrote: On further thinking, as such this shouldn't be a problem because all the WAL records before PARAMETER_CHANGE record will have sufficient information so that they can get decoded. However, with the

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/5/23 2:33 AM, Jeff Davis wrote: On Tue, 2023-04-04 at 14:55 -0400, Robert Haas wrote: Thanks for your continued work on $SUBJECT. I just took a look at 0004, Thanks Robert for the feedback! and I think that at the very least the commit message needs work. Agree. Perhaps a

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/4/23 8:13 PM, Jeff Davis wrote: On Tue, 2023-04-04 at 11:42 +0200, Drouvot, Bertrand wrote: Done in V58 and now this is as simple as: Minor comments on 0004 (address if you agree): Thanks for the review! * Consider static inline for WalSndWakeupProcessRequests()? Agree and

Re: Minimal logical decoding on standbys

2023-04-05 Thread Drouvot, Bertrand
Hi, On 4/4/23 7:53 PM, Andres Freund wrote: Hi, On 2023-04-04 18:54:33 +0200, Drouvot, Bertrand wrote: if (check_on_xid) { if (terminating) appendStringInfo(_msg, _("terminating process %d to release replication slot \"%s\" because it conflicts with

Re: Minimal logical decoding on standbys

2023-04-05 Thread Amit Kapila
On Mon, Apr 3, 2023 at 12:05 PM Amit Kapila wrote: > > On Mon, Apr 3, 2023 at 4:39 AM Alvaro Herrera wrote: > > > > > From 56a9559555918a99c202a0924f7b2ede9de4e75d Mon Sep 17 00:00:00 2001 > > > From: bdrouvotAWS > > > Date: Tue, 7 Feb 2023 08:59:47 + > > > Subject: [PATCH v52 3/6] Allow

Re: Minimal logical decoding on standbys

2023-04-04 Thread Andres Freund
Hi, On 2023-04-04 17:33:25 -0700, Jeff Davis wrote: > On Tue, 2023-04-04 at 14:55 -0400, Robert Haas wrote: > > That's presumably OK, in the > > sense that they'll go back to sleep and eventually wake up again, but > > it means they might end up chronically behind sending out WAL to > >

Re: Minimal logical decoding on standbys

2023-04-04 Thread Jeff Davis
On Tue, 2023-04-04 at 14:55 -0400, Robert Haas wrote: > Thanks for your continued work on $SUBJECT. I just took a look at > 0004, and I think that at the very least the commit message needs > work. Nobody who is not a hacker is going to understand what problem > this is fixing, because it makes

Re: Minimal logical decoding on standbys

2023-04-04 Thread Robert Haas
On Tue, Apr 4, 2023 at 5:44 AM Drouvot, Bertrand wrote: > Oh right, even better, thanks! > Done in V58 and now this is as simple as: > > + if (DoNotInvalidateSlot(s, xid, )) > { > /* then, we are not forcing for invalidation */ Thanks for

Re: Minimal logical decoding on standbys

2023-04-04 Thread Jeff Davis
On Tue, 2023-04-04 at 11:42 +0200, Drouvot, Bertrand wrote: > Done in V58 and now this is as simple as: Minor comments on 0004 (address if you agree): * Consider static inline for WalSndWakeupProcessRequests()? * Is the WalSndWakeup() in KeepFileRestoredFromArchive() more like the flush case?

Re: Minimal logical decoding on standbys

2023-04-04 Thread Andres Freund
Hi, On 2023-04-04 18:54:33 +0200, Drouvot, Bertrand wrote: > if (check_on_xid) > { > if (terminating) > appendStringInfo(_msg, _("terminating process %d to release > replication slot \"%s\" because it conflicts with recovery"), > pid, >

Re: Minimal logical decoding on standbys

2023-04-04 Thread Andres Freund
Hi, On 2023-04-04 13:21:38 +0200, Alvaro Herrera wrote: > On 2023-Apr-03, Andres Freund wrote: > > > Hm? That's what the _'s do. We build strings in parts in other places too. > > No, what _() does is mark each piece for translation separately. But a > translation cannot be done on string

Re: Minimal logical decoding on standbys

2023-04-04 Thread Drouvot, Bertrand
Hi, On 4/4/23 1:21 PM, Alvaro Herrera wrote: Hi, On 2023-Apr-03, Andres Freund wrote: Hm? That's what the _'s do. We build strings in parts in other places too. No, what _() does is mark each piece for translation separately. But a translation cannot be done on string pieces, and later

Re: Minimal logical decoding on standbys

2023-04-04 Thread Drouvot, Bertrand
Hi, On 4/4/23 3:43 PM, Amit Kapila wrote: On Tue, Apr 4, 2023 at 6:05 PM Drouvot, Bertrand I think we might want to consider slot's effective_xmin instead of data.xmin as we use that to store xmin_horizon when we build the full snapshot. Oh, I did not know about the 'effective_xmin' and was

Re: Minimal logical decoding on standbys

2023-04-04 Thread Amit Kapila
On Tue, Apr 4, 2023 at 6:05 PM Drouvot, Bertrand wrote: > > On 4/4/23 1:43 PM, Amit Kapila wrote: > > On Tue, Apr 4, 2023 at 3:14 PM Drouvot, Bertrand > > wrote: > >> > > > > > > +static inline bool > > +LogicalReplicationSlotXidsConflict(ReplicationSlot *s, TransactionId xid) > > +{ > > +

Re: Minimal logical decoding on standbys

2023-04-04 Thread Drouvot, Bertrand
Hi, On 4/4/23 1:43 PM, Amit Kapila wrote: On Tue, Apr 4, 2023 at 3:14 PM Drouvot, Bertrand wrote: +static inline bool +LogicalReplicationSlotXidsConflict(ReplicationSlot *s, TransactionId xid) +{ + TransactionId slot_xmin; + TransactionId slot_catalog_xmin; + + slot_xmin = s->data.xmin; +

Re: Minimal logical decoding on standbys

2023-04-04 Thread Amit Kapila
On Tue, Apr 4, 2023 at 3:14 PM Drouvot, Bertrand wrote: > +static inline bool +LogicalReplicationSlotXidsConflict(ReplicationSlot *s, TransactionId xid) +{ + TransactionId slot_xmin; + TransactionId slot_catalog_xmin; + + slot_xmin = s->data.xmin; + slot_catalog_xmin = s->data.catalog_xmin; + +

Re: Minimal logical decoding on standbys

2023-04-04 Thread Alvaro Herrera
Hi, On 2023-Apr-03, Andres Freund wrote: > Hm? That's what the _'s do. We build strings in parts in other places too. No, what _() does is mark each piece for translation separately. But a translation cannot be done on string pieces, and later have all the pieces appended together to form a

Re: Minimal logical decoding on standbys

2023-04-04 Thread Drouvot, Bertrand
Hi, On 4/4/23 9:48 AM, Masahiko Sawada wrote: On Tue, Apr 4, 2023 at 10:55 AM Masahiko Sawada wrote: Regarding 0004 patch: @@ -2626,6 +2626,12 @@ InitWalSenderSlot(void) walsnd->sync_standby_priority = 0; walsnd->latch = >procLatch;

Re: Minimal logical decoding on standbys

2023-04-04 Thread Drouvot, Bertrand
Hi, On 4/4/23 7:57 AM, Amit Kapila wrote: On Mon, Apr 3, 2023 at 8:51 PM Drouvot, Bertrand wrote: I made it as simple as: /* * If the slot is already invalid or is a non conflicting slot, we don't * need to do anything. */ islogical =

Re: Minimal logical decoding on standbys

2023-04-04 Thread Masahiko Sawada
On Tue, Apr 4, 2023 at 10:55 AM Masahiko Sawada wrote: > > On Tue, Apr 4, 2023 at 3:17 AM Drouvot, Bertrand > wrote: > > > > Hi, > > > > On 4/3/23 8:10 AM, Drouvot, Bertrand wrote: > > > Hi, > > > > > > On 4/3/23 7:35 AM, Amit Kapila wrote: > > >> On Mon, Apr 3, 2023 at 4:26 AM Jeff Davis

Re: Minimal logical decoding on standbys

2023-04-03 Thread Amit Kapila
On Mon, Apr 3, 2023 at 8:51 PM Drouvot, Bertrand wrote: > > On 4/2/23 10:10 PM, Andres Freund wrote: > > Hi, > >> restart_lsn = s->data.restart_lsn; > >> - > >> -/* > >> - * If the slot is already invalid or is fresh enough, we > >> don't need to > >> -

Re: Minimal logical decoding on standbys

2023-04-03 Thread Masahiko Sawada
On Tue, Apr 4, 2023 at 3:17 AM Drouvot, Bertrand wrote: > > Hi, > > On 4/3/23 8:10 AM, Drouvot, Bertrand wrote: > > Hi, > > > > On 4/3/23 7:35 AM, Amit Kapila wrote: > >> On Mon, Apr 3, 2023 at 4:26 AM Jeff Davis wrote: > >> > >> Agreed, even Bertrand and myself discussed the same approach few >

Re: Minimal logical decoding on standbys

2023-04-03 Thread Andres Freund
Hi, On 2023-04-03 17:34:52 +0200, Alvaro Herrera wrote: > On 2023-Apr-03, Drouvot, Bertrand wrote: > > > +/* > > + * Report terminating or conflicting message. > > + * > > + * For both, logical conflict on standby and obsolete slot are handled. > > + */ > > +static void > >

Re: Minimal logical decoding on standbys

2023-04-03 Thread Drouvot, Bertrand
Hi, On 4/3/23 8:10 AM, Drouvot, Bertrand wrote: Hi, On 4/3/23 7:35 AM, Amit Kapila wrote: On Mon, Apr 3, 2023 at 4:26 AM Jeff Davis wrote: Agreed, even Bertrand and myself discussed the same approach few emails above. BTW, if we have this selective logic to wake physical/logical walsenders

Re: Minimal logical decoding on standbys

2023-04-03 Thread Alvaro Herrera
On 2023-Apr-03, Drouvot, Bertrand wrote: > +/* > + * Report terminating or conflicting message. > + * > + * For both, logical conflict on standby and obsolete slot are handled. > + */ > +static void > +ReportTerminationInvalidation(bool terminating, bool islogical, int pid, > +

Re: Minimal logical decoding on standbys

2023-04-03 Thread Drouvot, Bertrand
Hi, On 4/2/23 10:10 PM, Andres Freund wrote: Hi, Btw, most of the patches have some things that pgindent will change (and some that my editor will highlight). It wouldn't hurt to run pgindent for the later patches... done. Pushed the WAL format change. Thanks! On 2023-04-02 10:27:45

Re: Minimal logical decoding on standbys

2023-04-03 Thread Amit Kapila
On Mon, Apr 3, 2023 at 4:39 AM Alvaro Herrera wrote: > > > From 56a9559555918a99c202a0924f7b2ede9de4e75d Mon Sep 17 00:00:00 2001 > > From: bdrouvotAWS > > Date: Tue, 7 Feb 2023 08:59:47 + > > Subject: [PATCH v52 3/6] Allow logical decoding on standby. > > > > Allow a logical slot to be

Re: Minimal logical decoding on standbys

2023-04-03 Thread Drouvot, Bertrand
Hi, On 4/3/23 7:35 AM, Amit Kapila wrote: On Mon, Apr 3, 2023 at 4:26 AM Jeff Davis wrote: On Fri, 2023-03-31 at 02:50 -0700, Jeff Davis wrote: But if the ConditionVariableEventSleep() API is added, then I think we should change the non-recovery case to use a CV as well for consistency, and

Re: Minimal logical decoding on standbys

2023-04-03 Thread Drouvot, Bertrand
Hi, On 4/3/23 7:20 AM, Amit Kapila wrote: On Mon, Apr 3, 2023 at 1:31 AM Jeff Davis wrote: On Sun, 2023-04-02 at 10:11 +0200, Drouvot, Bertrand wrote: I was thinking that, if a new LogicalWalSndWakeup() replaces "ConditionVariableBroadcast(>replayedCV);" in ApplyWalRecord() then, it could

Re: Minimal logical decoding on standbys

2023-04-02 Thread Amit Kapila
On Mon, Apr 3, 2023 at 4:26 AM Jeff Davis wrote: > > On Fri, 2023-03-31 at 02:50 -0700, Jeff Davis wrote: > > But if the ConditionVariableEventSleep() API is added, then I think > > we > > should change the non-recovery case to use a CV as well for > > consistency, and it would avoid the need for

Re: Minimal logical decoding on standbys

2023-04-02 Thread Amit Kapila
On Mon, Apr 3, 2023 at 1:31 AM Jeff Davis wrote: > > On Sun, 2023-04-02 at 10:11 +0200, Drouvot, Bertrand wrote: > > I was thinking that, if a new LogicalWalSndWakeup() replaces > > "ConditionVariableBroadcast(>replayedCV);" > > in ApplyWalRecord() then, it could be possible that some

Re: Minimal logical decoding on standbys

2023-04-02 Thread Alvaro Herrera
> From 56a9559555918a99c202a0924f7b2ede9de4e75d Mon Sep 17 00:00:00 2001 > From: bdrouvotAWS > Date: Tue, 7 Feb 2023 08:59:47 + > Subject: [PATCH v52 3/6] Allow logical decoding on standby. > > Allow a logical slot to be created on standby. Restrict its usage > or its creation if wal_level

Re: Minimal logical decoding on standbys

2023-04-02 Thread Jeff Davis
On Sun, 2023-04-02 at 15:29 -0700, Andres Freund wrote: > I agree that the *wait* has to go through condition_variable.c, but > it doesn't > seem right that creation of the WES needs to go through > condition_variable.c. The kind of WES required by a CV is an implementation detail, so I was

Re: Minimal logical decoding on standbys

2023-04-02 Thread Jeff Davis
On Fri, 2023-03-31 at 02:50 -0700, Jeff Davis wrote: > But if the ConditionVariableEventSleep() API is added, then I think > we > should change the non-recovery case to use a CV as well for > consistency, and it would avoid the need for WalSndWakeup(). It seems like what we ultimately want is for

Re: Minimal logical decoding on standbys

2023-04-02 Thread Andres Freund
Hi, On 2023-04-02 15:15:44 -0700, Jeff Davis wrote: > On Sun, 2023-04-02 at 14:35 -0700, Andres Freund wrote: > > Why not offer a function to add a CV to a WES? It seems somehow odd > > to require > > going through condition_variable.c to create a WES. > > I agree that it's a bit odd, but

Re: Minimal logical decoding on standbys

2023-04-02 Thread Jeff Davis
On Sun, 2023-04-02 at 14:35 -0700, Andres Freund wrote: > Why not offer a function to add a CV to a WES? It seems somehow odd > to require > going through condition_variable.c to create a WES. I agree that it's a bit odd, but remember that after waiting on a CV's latch, it needs to re-insert

Re: Minimal logical decoding on standbys

2023-04-02 Thread Andres Freund
Hi, On 2023-03-31 02:44:33 -0700, Jeff Davis wrote: > From 2f05cab9012950ae9290fccbb6366d50fc01553e Mon Sep 17 00:00:00 2001 > From: Jeff Davis > Date: Wed, 1 Mar 2023 20:02:42 -0800 > Subject: [PATCH v2] Introduce ConditionVariableEventSleep(). > > The new API takes a WaitEventSet which can

Re: Minimal logical decoding on standbys

2023-04-02 Thread Jeff Davis
On Fri, 2023-03-31 at 02:44 -0700, Jeff Davis wrote: > Thank you, done. I think the nearby line was also wrong, returning > true > when there was no timeout. I combined the lines and got rid of the > early return so it can check the list and timeout condition like > normal. Attached. On second

Re: Minimal logical decoding on standbys

2023-04-02 Thread Andres Freund
Hi, Btw, most of the patches have some things that pgindent will change (and some that my editor will highlight). It wouldn't hurt to run pgindent for the later patches... Pushed the WAL format change. On 2023-04-02 10:27:45 +0200, Drouvot, Bertrand wrote: > During WAL replay on standby, when

Re: Minimal logical decoding on standbys

2023-04-02 Thread Jeff Davis
On Sun, 2023-04-02 at 10:11 +0200, Drouvot, Bertrand wrote: > I was thinking that, if a new LogicalWalSndWakeup() replaces > "ConditionVariableBroadcast(>replayedCV);" > in ApplyWalRecord() then, it could be possible that some walsender(s) > are requested to wake up while they are actually doing

Re: Minimal logical decoding on standbys

2023-04-02 Thread Drouvot, Bertrand
Hi, On 4/1/23 6:50 AM, Amit Kapila wrote: On Fri, Mar 31, 2023 at 7:14 PM Drouvot, Bertrand wrote: That sounds like a good idea. We could imagine creating a LogicalWalSndWakeup() doing the Walsender(s) triage based on a new variable (as you suggest). But, it looks to me that we: - would

Re: Minimal logical decoding on standbys

2023-04-01 Thread Andres Freund
Hi, On 2023-03-31 12:45:51 +0200, Drouvot, Bertrand wrote: > On 3/31/23 6:33 AM, Andres Freund wrote: > > Hi, > > > > On 2023-03-30 18:23:41 +0200, Drouvot, Bertrand wrote: > > > On 3/30/23 9:04 AM, Andres Freund wrote: > > > > I think this commit is ready to go. Unless somebody thinks

  1   2   3   4   >