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 1txSA7-009ZkE-Fb for pgsql-general@arkaria.postgresql.org; Wed, 26 Mar 2025 14:55:23 +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 1txSA6-004mzY-4y for pgsql-general@arkaria.postgresql.org; Wed, 26 Mar 2025 14:55:22 +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 1txSA5-004mzM-MO for pgsql-general@lists.postgresql.org; Wed, 26 Mar 2025 14:55:21 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1txSA3-001FrZ-2p for pgsql-general@postgresql.org; Wed, 26 Mar 2025 14:55:20 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-227a8cdd241so21335655ad.3 for ; Wed, 26 Mar 2025 07:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743000919; x=1743605719; darn=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=GSSOLCVxBH3p0/TZZARahA4L1CyYyzDc88myf0HaHis=; b=Jg5KWi3JVxHAfMr9OxbDLF29lsqFvy2gCJ5csJj5P885EJzo/ModEWdTizJIz54F70 I9xEqT7P19JbnFalmUa9bzMAPxDfrvcJWIb31ra6jZIqT8QTapNXClcSBObW6c+lt49W T9rmlv+5wWieMDeU0V/4D+gAP2Acp1CrARXRuhp8zOuMXxMaTIK6chYbpGuqKx//wUkr +ceOZpIcaPT/uFRFmWzio+lIO3kO31cJhpoESLJJk/HPVV0PQ+cJi38w5Xj8XcUEQt13 icHnjBMFlxLqStzLrX/swXmbybTQZkhk0goQ9cWwhIRfUptrzPDbQBNgC+1xXgRTJkWt aJBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743000919; x=1743605719; 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=GSSOLCVxBH3p0/TZZARahA4L1CyYyzDc88myf0HaHis=; b=heTLO9hu1ur8cnKTMTS/X31deBPQKfdXMTzfZ1k1PX1snVxJrYAzj7E9dGuUsY9For kSULglMLMzyD9CjSvB7EesGWtiw/S6nuMVmRxl4RG53RjJKx9REMs7foCnFQcLYhlSzN IN8l7yExmqRgkGroYaACVC9WL6Iba8ZseI3UupbrmKeyTWK5siEkGX0mg3U9h/3tr+Xe LF6E9dD82fQxvvS5Vn/qZRZbZDKTIQdlr4sDOVM32o0u1oNUpZFpjtuYYzKepx+6avqP WmSxUm2bwOGItfm6aHP0++DW6FKKSoWoW5M8sJ0vqT/kAtdD673HhkNQ/TXFv4DMai98 sIbg== X-Gm-Message-State: AOJu0YxSBX+lxN1iZdwKXlIT7UADNEFlWZe1flNchAcTp7z+930Rgtu/ jUwDPxiFVsyFv3ulCvSWLRlRw9wHGJ/ltH1dWUFLwihSu+rzqAVMDaa8mVdBUUC0g8eO0PS9CKO gialUb+3qgDnsJXCfafdMfp5M2ok= X-Gm-Gg: ASbGnctQNRZnkOe+b1G+6q/uAdps8x9UgNpjo3Tf3y7YUA1pMCQb0Tm+KIviAui9zWC irBS0soZ9XUmvs5BPq6IRGt8KFx0XxsfHUE20ef7WKpbita9WblSnfadtpMksMTcH1HdCTT0RXU 2FvXZm9mgc/CTXNer94c4HGSsw X-Google-Smtp-Source: AGHT+IHAs1ISbuVIQZusnVvsXx3brnVJ7lUdxuycg3lo5s/9xUZtMgjG8Ymnpcv7CVaR4EqqJoqCDTsO7f07C3v8j+c= X-Received: by 2002:a05:6a00:13a0:b0:736:ab48:18f0 with SMTP id d2e1a72fcca58-7390597ec9amr25803240b3a.1.1743000918397; Wed, 26 Mar 2025 07:55:18 -0700 (PDT) MIME-Version: 1.0 References: <270FB587-2E83-4EB0-9FD6-07541F2A6A17@thebuild.com> <3CBAE3E1-4ECB-4936-908E-3F03B79886F8@thebuild.com> In-Reply-To: <3CBAE3E1-4ECB-4936-908E-3F03B79886F8@thebuild.com> From: Phillip Diffley Date: Wed, 26 Mar 2025 09:55:06 -0500 X-Gm-Features: AQ5f1JqOnbbGDyk_hLvSFXQm7Bsb29_RoP2dLBPgiM3bJtFLi_F9WXNuItn8w40 Message-ID: Subject: Re: Replication slot WAL reservation To: Christophe Pettus Cc: pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="000000000000959cd206314006f8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000959cd206314006f8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > You're looking for Standby Status Update Awesome! I completely missed that. > Transactions are always presented to the output plugin in commit order Ok great. I think that is what I needed to know. Just to confirm, it sounds like the order messages are sent from the output plugin is what matters here. When you update confirmed_flush_lsn to LSN "A", any messages that were sent by the output plugin after the message with LSN "A" will be replayable. Any messages sent by the output plugin before the message with LSN "A" will most likely not be replayed, since their data is freed for deletion. Is that correct? On Tue, Mar 25, 2025 at 11:32=E2=80=AFPM Christophe Pettus wrote: > > > > On Mar 25, 2025, at 20:56, Phillip Diffley > wrote: > > > > Is there a message type that is used to confirm what logs have been > successfully consumed? > > You're looking for Standby Status Update: > > > https://www.postgresql.org/docs/current/protocol-replication.html#PROTOCO= L-REPLICATION-STANDBY-STATUS-UPDATE > > The logical replication protocol is a superset of the binary replication > protocol, so many of the same messages are used. > > > The part I am uncertain about is what "after" means here, since LSNs ar= e > not presented in order, and the order of data streamed over the replicati= on > slot does not match the order of the data in the WAL. > > I think there's a misunderstanding here (possibly my fault). Transaction= s > are always presented to the output plugin in commit order, and LSNs can b= e > reliably used to determine the time ordering of commits. LSNs are exactl= y > what is used to determine how far into the WAL the replication slot has > gotten. --000000000000959cd206314006f8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> You're looking for Standby Status Update

Awesome! I completely missed that.
> Transactions are always presented to the output plugin in = commit order

Ok great. I think that is what I need= ed to know.=C2=A0

Just to confirm, it sounds like = the order messages are sent from the output plugin is what matters here. Wh= en you update confirmed_flush_lsn to LSN "A", any messages that w= ere sent by the output plugin after the message with LSN "A" will= be replayable. Any messages sent by the output plugin before the message w= ith LSN "A" will most likely not be replayed, since their data is= freed for deletion. Is that correct?

On Tue, Ma= r 25, 2025 at 11:32=E2=80=AFPM Christophe Pettus <xof@thebuild.com> wrote:


> On Mar 25, 2025, at 20:56, Phillip Diffley <phillip6402@gmail.com> wrote: >
> Is there a message type that is used to confirm what logs have been su= ccessfully consumed?

You're looking for Standby Status Update:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 https://www.postgresql.org/docs/current= /protocol-replication.html#PROTOCOL-REPLICATION-STANDBY-STATUS-UPDATE
The logical replication protocol is a superset of the binary replication pr= otocol, so many of the same messages are used.

> The part I am uncertain about is what "after" means here, si= nce LSNs are not presented in order, and the order of data streamed over th= e replication slot does not match the order of the data in the WAL.

I think there's a misunderstanding here (possibly my fault).=C2=A0 Tran= sactions are always presented to the output plugin in commit order, and LSN= s can be reliably used to determine the time ordering of commits.=C2=A0 LSN= s are exactly what is used to determine how far into the WAL the replicatio= n slot has gotten.
--000000000000959cd206314006f8--