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 1u0fS0-005WIi-C8 for pgsql-general@arkaria.postgresql.org; Fri, 04 Apr 2025 11:43:08 +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 1u0fRy-00GyYy-FC for pgsql-general@arkaria.postgresql.org; Fri, 04 Apr 2025 11:43:06 +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 1u0fRy-00GyYq-3K for pgsql-general@lists.postgresql.org; Fri, 04 Apr 2025 11:43:06 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u0fRw-002uNX-19 for pgsql-general@lists.postgresql.org; Fri, 04 Apr 2025 11:43:05 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-af6a315b491so1684594a12.1 for ; Fri, 04 Apr 2025 04:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743766983; x=1744371783; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=HtCWXUSg87/GzlVRVc9M1S95CC92EJpuyCs89m2MyCs=; b=COwq5+RHE3/JXtYuAl8Wt0pbZG6RBEb1PSM8IQlh7lx8nwsrMgJxogBec14oufTpgq Imr0s2Im1WW9SiKncT1YdZVa8DVN7M/z7qkx4Vlu8QIV2XlmJCYbNhX7nNDJYISzqGZ+ 44gATG8G7mrlu2bf4VZvHR8ebanLfMvpSdSnAStwJK/6LW6Eo941h8QeF037sLm0EjHv l4cxcFdQxjU3QIwrsy6ymxwKkkG/0emD07Jlgf6fGCvo0sf5uSzEQGconN/f7XQlTLC3 PbOKrqQHywZqJ7wC4mmvxPEzgO9zQrsH3ify0oVHP+CeTZ00nkGKF4ZWaUOtd4HXC5zq bu2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743766983; x=1744371783; h=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=HtCWXUSg87/GzlVRVc9M1S95CC92EJpuyCs89m2MyCs=; b=h/WsJlqPrWI0EvxhvCnDlhIDUtPUJUyWuqdGNhG6LDimd8SqpmJoSJQ0qiPZdSoLiI y4bg9H6jTJ7YvE5HFJYWHD74J8z6gpLQhseLLeIoezH0i4BQjFWIh1Y16My64VQYoG3u m0CoHEBKOdu0LjLORIPpsByN1l6j3CtmHTw7+z1YWJLyHou/fZG7Jb4Gr16bdqWeB03y 3ubyFB1auKD8AcSYvbt9C1ZzFwgJVRmG/LZ9Gl/o3TUzy7YRFHPRU+G13SDeW7fXLAtW VYvkmYKFmnstI8KJd4YKVSP0wgaFOxZ+I/2NG5Cvvu3AMoRnyp83ndepIlxF4e1k47TE DsBQ== X-Gm-Message-State: AOJu0YzVnf67hqsweWdxtn07V4nMsp582xIMkNTDxsLM6Yz9+HAhZ1za HC23DsgOC+HXXjkggopZa2HJZixZ9aZ/MytYgh7ZyUk47w1tvjZZuEOYqfwPx8FMhfbPvOP5hQ8 Ko9sIRfmauzyknoSBOjG+wD+OAdOgeuYx X-Gm-Gg: ASbGncv5x1Wh66vSq2nnmVP8AlG6+zlatnL5EQgborULuO8MNwlZnKS/RehgBuaut3v KBchxaXrcuavaiYEV//G1tgqbwF8LYMblHRThB42NvrsqNySCnuFLHoLLeVjVt0GyqtYaI7gFkk EKTNeJfAQgIfDGgncQuc7HM5JCGPI= X-Google-Smtp-Source: AGHT+IHQLTRbCQ4+nEs8RooqSRpDbf/biI9aXN5dfre+F6sDjmG6AHU6TRxQz+5iswRl0NSxtDFX71pUS4rbrkeaBrU= X-Received: by 2002:a17:90a:c890:b0:2ff:53a4:74f0 with SMTP id 98e67ed59e1d1-306a48acec4mr4358733a91.29.1743766982901; Fri, 04 Apr 2025 04:43:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Willy-Bas Loos Date: Fri, 4 Apr 2025 13:42:50 +0200 X-Gm-Features: AQ5f1JqjgNvKGavNI7_3YboK1zyCWguQJOM_i9W0zejlukIwGypV6BRFtB2wjqk Message-ID: Subject: Re: find replication slots that "belong" to a publication To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000964b930631f26391" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000964b930631f26391 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable postgres 13 BTW On Fri, Apr 4, 2025 at 10:58=E2=80=AFAM Willy-Bas Loos = wrote: > Hi! > > I'm looking for a way to find out if there are still replication slots > active for a publication before dropping the publication in an automated > way. The idea is that the publication is thought not to be needed any > longer, but we want to make sure. > > I'm having trouble finding a link between a publication, the subscription= s > and the replication slots. Especially when you don't want to make > assumptions about any subscriber nodes, so you are restricted to the > publisher node. > > The best I could find was a query listed in pg_stat_activity that lists > the slot name and the publication name: > START_REPLICATION SLOT "my_slot" LOGICAL 5DD1/3E56D360 (proto_version '1'= , > publication_names '"my_publication"') > > I don't like the idea of using string manipulation on such query strings > to get the information I need. Postgres must have a way to compose this > query. > Can anyone tell me a way to find replication slots that belong to a > publication? > > -- > Willy-Bas Loos > --=20 Willy-Bas Loos --000000000000964b930631f26391 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
postgres 13 BTW

On Fri, Apr 4, 2025 a= t 10:58=E2=80=AFAM Willy-Bas Loos <willybas@gmail.com> wrote:
Hi!

I'= ;m looking for a way to find out if there are still replication slots activ= e for a publication before dropping the publication in an automated way. Th= e idea is that the publication is thought not to be needed any longer, but = we want to make sure.

I'm having trouble findi= ng a link between a publication, the subscriptions and the replication slot= s. Especially when you don't want to make assumptions about any subscri= ber nodes, so you are restricted to the publisher node.

The best I could find was a query listed in pg_stat_activi= ty that lists the slot name and the publication name:
START_REPLI= CATION SLOT "my_slot" LOGICAL 5DD1/3E56D360 (proto_version '1= ', publication_names '"my_publication"')
I don't like the idea of using string manipulat= ion on such query strings to get the information I need. Postgres must have= a way to compose this query.
Can anyone tell me a way to find re= plication slots that belong to a publication?

--
Willy-Bas Loos


--
Willy-Bas Loos
--000000000000964b930631f26391--