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 1u1t9c-009uDG-Dl for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 20:33:12 +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 1u1t9a-003g13-DP for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 20:33:10 +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 1u1t9Z-003g0t-Um for pgsql-general@lists.postgresql.org; Mon, 07 Apr 2025 20:33:10 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u1t9Y-003XWD-1K for pgsql-general@lists.postgresql.org; Mon, 07 Apr 2025 20:33:09 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-30155bbbed9so3619091a91.1 for ; Mon, 07 Apr 2025 13:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744057987; x=1744662787; 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=0LkVk8KgrCyiB3KJtlxLYu8AIcbjJFQF0u1aUS6I1TA=; b=CTbjwUeZh1zLQaJbO0sDzOfVqXlqOSO5b3T34WcLW/O7mKxDUlDG2S1zIeSsle//HT R0q5LdHjDlVFCC6v3BigdEQl/aIMeI6JPgwofdOuEEpqWWgyvsY6Fntq0ahr82DpLPu9 wC0qCWsaWISauSgNy2LlvGkOZyN7Z9TfxSUyWDV7NSxNTGjWvZTAr/n7JKDlCl02qYHw elTvRCdafu8qQLeEXsD2+TpoHSGGB+bhAUVOTMGm21AEDeWSYy3gmnVWpRGq5x+iGrIV Zj0BFxUYN+hEaPHSr+ESJ8FmTKZmFA4I629NQYxLqaZ80HphJ+TsLvxk6xkmXJSWYmjj AiMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744057987; x=1744662787; 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=0LkVk8KgrCyiB3KJtlxLYu8AIcbjJFQF0u1aUS6I1TA=; b=CxrhiyZCqLS7XInPfTJY5kTl7FZe9Rfz4efmieshGGHOzpPJfqtk7WwohM8mK5TsvJ aKFWOZnwCJqRIsukZsNwKzRkVrLV6SXYRmtQIatCOls+4HT0WSMUDNSzDAKXZiQ8T2Bn uixjHQCEWErRz5i2jA734mbikcnoaqROegYkcl4QKjn2qiiNwUIblNJ7p5B6/TzZX5FL t4FcxFiV2QjKbAtDx9cZSNoJQpxUYOJbvQsf1Jz2a5flrZS08RUX2hjSaDJ7DMy6K9qr wH56S+Idh/6mgOS9TZb/h0fASgI+WuJUG0U3NKOV8pecuq/Q3uM2w7WKYtsl8JwDJolQ 8pAw== X-Forwarded-Encrypted: i=1; AJvYcCUUTY8dv7DF0qKH0Opn2PZMcQ8LasheQYFh+lmu5J4WNk+IIlw5n4oZ4xENe4g3CsaBjp3DoF/XE9zFP/44@lists.postgresql.org X-Gm-Message-State: AOJu0YzZo+DYQrNu88sPUmukkr8nUoQ+PXt6GuojDSansZFjr1W0nrLR UELjvQ2NTjkTGepsa7TF2pmLMAGQgjOpiyQAaqs1a5bakThf3mbq+1bbstoDfyy26S8tNndaTxT 0nXgB/PodEQrQPwlbbUX2wNYNCKCoq8AR X-Gm-Gg: ASbGnct7basEg5nmBrb9lZ+sf37tOEeJNMwInAROjSPOwn24KYY8KxuMxPExpWJEzN9 DoH5UTerspze0qZGIbva6PPTKb3YFqLkvPiMoyKGbaOqTrkvQw2rCtev297B+IXgpcF9LPYhFGo wTPKZAbEGz68/u7HcD8hh7lWugaQ== X-Google-Smtp-Source: AGHT+IFVefmpQWZ3fClJYk+NGldVyBC0D6XBn6XoAZG883OzhEKyXmoGmXCgs7q/NzxkP0aiG6OSLKqPE3Bw/YG4K3k= X-Received: by 2002:a17:90b:2709:b0:2f9:c139:b61f with SMTP id 98e67ed59e1d1-306a48650dfmr22762055a91.14.1744057987316; Mon, 07 Apr 2025 13:33:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Willy-Bas Loos Date: Mon, 7 Apr 2025 22:32:55 +0200 X-Gm-Features: ATxdqUHVwXaJbn-tX8E2w4jktOHTd-alYOUb5w0pJlb9aF-nPKNyjv5i68PA_94 Message-ID: Subject: Re: find replication slots that "belong" to a publication To: Laurenz Albe Cc: Justin , pgsql-general Content-Type: multipart/alternative; boundary="000000000000cd4534063236247d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000cd4534063236247d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Laurenz, Thanks for answering! I find it very strange, because the publication is needed to make a subscription, which makes the slot. Thanks for looking into it and helping me understand. Cheers! Willy-Bas Loos On Mon, Apr 7, 2025 at 3:31=E2=80=AFPM Laurenz Albe wrote: > On Mon, 2025-04-07 at 12:16 +0200, Willy-Bas Loos wrote: > > My question is not so much about "can i drop a certain replication > slot", > > more about "does this publication still have any replication slots?". > > Or, if you will: "what's the publication for this replication slot?". > > > > I've double checked the views that you suggested, and I found that I ca= n > relate > > the WAL sender processes to replication slots through > pg_replication_slots.active_pid . > > I've also looked into replication origins. > > > > But I can't find a link to the publication. And that's what I need to > know. > > I don't think that there is a connection between a publication and a > replication slot. That connection is only made when a subscriber connect= s > and runs the START_REPLICATION command [1] and specifies the "pgoutput" > plugin with the "publication_names" option [2]. > > I don't think you can see that information reflected in a system view > on the primary. You'd have to query "pg_subscription" on the standby. > > Yours, > Laurenz Albe > > > [1]: > https://www.postgresql.org/docs/current/protocol-replication.html#PROTOCO= L-REPLICATION-START-REPLICATION-SLOT-LOGICAL > [2]: > https://www.postgresql.org/docs/current/protocol-logical-replication.html= #PROTOCOL-LOGICAL-REPLICATION-PARAMS > --=20 Willy-Bas Loos --000000000000cd4534063236247d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Laurenz,

Thanks for answering!
I find it very strange, because the p= ublication is needed to make a subscription, which makes the slot.
Thanks for looking into it and helping me understand.

Cheers!
Willy-Bas Loos


On Mon, Apr 7, 2025 at 3:31=E2=80=AFPM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
<= /div>
On Mon, 2025-04-07 a= t 12:16 +0200, Willy-Bas Loos wrote:
> My question is not so much about "can i drop a certain replicatio= n slot",=C2=A0
> more about "does this publication still have any replication slot= s?".
> Or, if you will: "what's the publication for this replication= slot?".
>
> I've double checked the views that you suggested, and I found that= I can relate
> the WAL sender processes to replication slots through pg_replication_s= lots.active_pid .
> I've also looked into replication origins.
>
> But I can't find a link to the publication. And that's what I = need to know.

I don't think that there is a connection between a publication and a replication slot.=C2=A0 That connection is only made when a subscriber conn= ects
and runs the START_REPLICATION command [1] and specifies the "pgoutput= "
plugin with the "publication_names" option [2].

I don't think you can see that information reflected in a system view on the primary.=C2=A0 You'd have to query "pg_subscription" o= n the standby.

Yours,
Laurenz Albe


=C2=A0[1]: https://www.postgresql.org/docs/current/protoco= l-replication.html#PROTOCOL-REPLICATION-START-REPLICATION-SLOT-LOGICAL<= br> =C2=A0[2]: https://www.postgresql.org/docs/current/protocol-logica= l-replication.html#PROTOCOL-LOGICAL-REPLICATION-PARAMS


--
Willy-Bas Loos
--000000000000cd4534063236247d--