Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3Ey6-00BPgt-LX for pgsql-committers@arkaria.postgresql.org; Tue, 22 Oct 2024 13:30:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3Ey4-00HIdW-Rp for pgsql-committers@arkaria.postgresql.org; Tue, 22 Oct 2024 13:30:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3Ey4-00HIai-Cx for pgsql-committers@lists.postgresql.org; Tue, 22 Oct 2024 13:30:36 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t3Ey1-002I2I-VT for pgsql-committers@lists.postgresql.org; Tue, 22 Oct 2024 13:30:35 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a9a628b68a7so732757466b.2 for ; Tue, 22 Oct 2024 06:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729603832; x=1730208632; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Dm5WAcv5tjZi6QtObQK6IQrnHhoP+CDGIZJfhnLqvkM=; b=lEVWck++zfHwQCGpimrbAFF04cVcel3KjlnTB7XENC7pIa41qjtGIMBoyt/xZEXZLw rfNUTO3c7Quu+Esi/sePON0+7DEDAyEEodpSRtmx3aPAa3mtk4RU8K5xCSkFZpSeyEME BdDYet8/UDnHGTQoWrKc46KE7EFHaFQ9Lhn173NVFXnunRdZZFSXcSAH2Z1DS8EJbhRH ufaa093eMniN5a+sUgsZZFcdaT3GHR9ZKOUcYHpItUv0BpbKi+AD7diLAwvjkPDn3Df7 5jlskIMN0K5dGtBPC6qgiHeyLcdsPSds0uaHGuhzqkXjbqQ6y2bxkWy6WYzab3ldrgXc W4ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729603832; x=1730208632; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Dm5WAcv5tjZi6QtObQK6IQrnHhoP+CDGIZJfhnLqvkM=; b=AFB7L//0AZfMOM0dMN7El2yZL9JgxGReZDI9XUxI0lFVUVPiMPaswyjtT3aF6nZyfN QuwG9UBHc3ROMHFy3Uu/+hu5cDMq/3wJsmjhZ6Upv8CWNi2GEPbaZKPodQ47U7DOAqbL sGYWl2nGvtvU63XMg8jqnZo9ct/yPdHNMv1JSIsUfs8qaD253b6AM0HzDp94BvOaNRCh K5F9Yg/SIU5ULGA5dzytGkvxjg1MF63PpUCVmFVI/xdRKvXvURw9dmM8I9lkVvPlfN/4 jlB1PAid2koBTgga8acvVbJ0HtLXfE0kIE8wbwGgCDnVhqp9HKiHMUxw9l6XCdtN3BGp Bvew== X-Forwarded-Encrypted: i=1; AJvYcCWHoAY8xPSjzwO93NVUZ34BpxH/gPdt7OHfAR80I1h17Z5PGMM++3RHUqt5l5XBIpVZaAEUnTHa7izuzgEoSXWf@lists.postgresql.org X-Gm-Message-State: AOJu0Yx7KYi9r0uNKc/Sd5q5GgbtdBXZESgq9EWtKEcZ9ALc7BI6XQIL ou05ayar/Hz/KnyMxm2xFVvFm7f4Enh4pEtCwGe/tnSyfACpqktpO89BjVJGCWcIbLd0J9YJjfL u7cYBnO/PYHSty/cLGeZ4fy36ThQ= X-Google-Smtp-Source: AGHT+IHWYrg9aZKSSdEbuwWFT2P7xzST6ai6HiB4voIKiECqWMR44gj8j4nGUjS2ilBO0C6H+XLYQoDmNxVxKcIIU80= X-Received: by 2002:a17:907:7247:b0:a99:88ab:c7cb with SMTP id a640c23a62f3a-a9a69a80a70mr1554113466b.33.1729603831965; Tue, 22 Oct 2024 06:30:31 -0700 (PDT) MIME-Version: 1.0 References: <18c0fa64-0475-415e-a1bd-665d922c5201@eisentraut.org> <1f5b399a-76b1-48e1-87b0-f511e61818f3@eisentraut.org> In-Reply-To: From: Pavel Borisov Date: Tue, 22 Oct 2024 17:30:20 +0400 Message-ID: Subject: Re: pgsql: Implement pg_wal_replay_wait() stored procedure To: Alexander Korotkov Cc: Peter Eisentraut , Michael Paquier , pgsql-committers@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000001af9e062510c633" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000001af9e062510c633 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Alexander! On Tue, 22 Oct 2024 at 13:26, Alexander Korotkov wrote: > On Wed, Oct 16, 2024 at 11:20=E2=80=AFPM Alexander Korotkov > wrote: > > > > On Wed, Oct 16, 2024 at 10:35=E2=80=AFPM Peter Eisentraut > wrote: > > > On 02.09.24 01:55, Alexander Korotkov wrote: > > > > On Mon, Sep 2, 2024 at 2:28=E2=80=AFAM Michael Paquier > wrote: > > > >> On Sun, Sep 01, 2024 at 10:35:27PM +0300, Alexander Korotkov wrote= : > > > >>> This path hasn't changes since the patch revision when it was a > > > >>> utility command. I agree that this doesn't look like proper path > for > > > >>> stored procedure. But I don't think src/backend/utils/adt is > > > >>> appropriate path either, because it's not really about data type. > > > >>> pg_wal_replay_wait() looks a good neighbor for > > > >>> pg_wal_replay_pause()/pg_wal_replay_resume() and other WAL-relate= d > > > >>> functions. So, what about moving it to src/backend/access/transa= m? > > > >> > > > >> Moving the new function to xlogfuncs.c while publishing > > > >> WaitForLSNReplay() makes sense to me. > > > > > > > > Thank you for proposal. I like this. > > > > > > > > Could you, please, check the attached patch? > > > > > > We still have stuff in src/backend/commands/waitlsn.c that is nothing > > > like a "command". You have moved some stuff elsewhere, but what are > you > > > planning to do with the rest? > > > > Thank you for spotting this another time. What about moving that > > somewhere like src/backend/access/transam/xlogwait.c ? > > Implemented this as a separate patch (0001). Also rebased other > pending patches on that. 0004 now revises header comment of > xlogwait.c with new procedure signature. > I've looked at v5 of a patchset. 0001: Looks completely ok. 0002: As stated in latch.c - WL_POSTMASTER_DEATH: Wait for postmaster to die - WL_EXIT_ON_PM_DEATH: Exit immediately if the postmaster dies * wakeEvents must include either WL_EXIT_ON_PM_DEATH for automatic exit * if the postmaster dies or WL_POSTMASTER_DEATH for a flag set in the * return value if the postmaster dies It's not completely clear to me if these comments need some clarification (not related to the patchset), or if we should look for WL_EXIT_ON_PM_DEATH for immediately FATAL. Or waiting for postmaster to die on WL_POSTMASTER_DEATH instead of just fatal immediately? 0003: Besides refactor it looks that deleteLSNWaiter() is added in WaitForLSNReplay. Maybe it's worth mentioning in the commit message. Maybe refactoring for loop for assigning result variable and breaking a loop instead of immediate return would look better and lead to natural call of after the loop before returning. 0004: Comment: + * Waits until recovery replays the target LSN with optional timeout. Throw + * an error on failure. may need mentioning "Unless no_error provided throws an error on failure" Otherwise the patch looks good. Regards, Pavel Borisov Supabase --00000000000001af9e062510c633 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, Alexander!

On Tue, 22 Oct 2024 at 13:2= 6, Alexander Korotkov <aekorotko= v@gmail.com> wrote:
On Wed, Oct 16, 2024 at 11:20=E2=80=AFPM Alexander Korotkov
<aekorotkov@gm= ail.com> wrote:
>
> On Wed, Oct 16, 2024 at 10:35=E2=80=AFPM Peter Eisentraut <peter@eisentraut.org= > wrote:
> > On 02.09.24 01:55, Alexander Korotkov wrote:
> > > On Mon, Sep 2, 2024 at 2:28=E2=80=AFAM Michael Paquier <<= a href=3D"mailto:michael@paquier.xyz" target=3D"_blank">michael@paquier.xyz= > wrote:
> > >> On Sun, Sep 01, 2024 at 10:35:27PM +0300, Alexander Koro= tkov wrote:
> > >>> This path hasn't changes since the patch revisio= n when it was a
> > >>> utility command.=C2=A0 I agree that this doesn't= look like proper path for
> > >>> stored procedure.=C2=A0 But I don't think src/ba= ckend/utils/adt is
> > >>> appropriate path either, because it's not really= about data type.
> > >>> pg_wal_replay_wait() looks a good neighbor for
> > >>> pg_wal_replay_pause()/pg_wal_replay_resume() and oth= er WAL-related
> > >>> functions.=C2=A0 So, what about moving it to src/bac= kend/access/transam?
> > >>
> > >> Moving the new function to xlogfuncs.c while publishing<= br> > > >> WaitForLSNReplay() makes sense to me.
> > >
> > > Thank you for proposal.=C2=A0 I like this.
> > >
> > > Could you, please, check the attached patch?
> >
> > We still have stuff in src/backend/commands/waitlsn.c that is not= hing
> > like a "command".=C2=A0 You have moved some stuff elsew= here, but what are you
> > planning to do with the rest?
>
> Thank you for spotting this another time.=C2=A0 What about moving that=
> somewhere like src/backend/access/transam/xlogwait.c ?

Implemented this as a separate patch (0001).=C2=A0 Also rebased other
pending patches on that.=C2=A0 0004 now revises header comment of
xlogwait.c with new procedure signature.

I've looked at v5 of a patchset.

0001:
=
Looks completely ok.

0002:

As stated in latch.c

- WL_POSTMASTER_DEATH:= Wait for postmaster to die
- WL_EXIT_ON_PM_DEATH: Exit immediate= ly if the postmaster dies

=C2=A0* wakeEvents m= ust include either WL_EXIT_ON_PM_DEATH for automatic exit
=C2=A0* if the= postmaster dies or WL_POSTMASTER_DEATH for a flag set in the
=C2=A0* re= turn value if the postmaster dies

It's not= completely clear to me if these comments need some clarification (not rela= ted to the patchset), or if we should look for WL_EXIT_ON_PM_DEATH for imme= diately FATAL. Or waiting for postmaster to die on WL_POSTMASTER_DEATH=C2= =A0instead of just fatal immediately?

0003:
<= div>Besides refactor it looks that=C2=A0deleteLSNWaiter() is added in=C2=A0= WaitForLSNReplay. Maybe it's worth mentioning in the commit message.
Maybe refactoring for loop for assigning result variable and breaki= ng a loop instead of immediate return would look better and lead to natural= call of after the loop before returning.

0004:

Comment:
+ * Waits until recovery replays = the target LSN with optional timeout.=C2=A0 Throw
+ * an error on fail= ure.
may need mentioning "Unless no_er= ror provided throws an error on failure"

Otherwise the patch looks good.

Regards,<= /div>
Pavel Borisov
Supabase
--00000000000001af9e062510c633--