public inbox for [email protected]  
help / color / mirror / Atom feed
From: Hayato Kuroda (Fujitsu) <[email protected]>
To: 'Fujii Masao' <[email protected]>
To: David G. Johnston <[email protected]>
Cc: Ashutosh Bapat <[email protected]>
Cc: [email protected] <[email protected]>
Cc: 'vignesh C' <[email protected]>
Subject: RE: pg_recvlogical requires -d but not described on the documentation
Date: Wed, 19 Mar 2025 02:32:26 +0000
Message-ID: <OSCPR01MB149660CCE2ADCC54A11F57E09F5D92@OSCPR01MB14966.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <[email protected]>
References: <OSCPR01MB14966930B4357BAE8C9D68A8AF5C72@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<CAExHW5uOprZgj2rVQ0HT3ckr+fVvhG-DvcVT+wfmwnwynH00pw@mail.gmail.com>
	<OSCPR01MB149660D1F436F8B82912FCB53F5C72@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<CAExHW5v94uRcr4f3+yhLrLX8UeYusJB06mcSqfdvu8fYUmVc=Q@mail.gmail.com>
	<OS7PR01MB14968CC4F20B99B8E1508CE81F5C32@OS7PR01MB14968.jpnprd01.prod.outlook.com>
	<CAKFQuwYWVT84GM2OqRx8EqNrfzNM-zbpQ5Y2bA1dPO9jUgo_Kg@mail.gmail.com>
	<[email protected]>
	<OSCPR01MB14966F6BA7B93EF637D256394F5DE2@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<OSCPR01MB149668F472C57FEBDCC480E90F5DE2@OSCPR01MB14966.jpnprd01.prod.outlook.com>
	<[email protected]>

Dear Fujii-san,

> It looks like commit 0c013e08cfb introduced a bug that causes "pg_recvlogical
> --drop-slot"
> without --dbname to check whether it's connected to a specific database and fail
> if it's not.
> 
> This commit was added before 9.5, while pg_recvlogical was introduced in 9.4. On
> my env,
> "pg_recvlogical --drop-slot" without --dbname worked as expected in 9.4 but
> started
> failing in 9.5 or later.
> 
> So, I think the proper fix is to avoid raising a fatal error even when not connected
> to
> a specific database in --drop-slot action.

+1. I created patch to fix it. 0001 was completely same as you did.

Best regards,
Hayato Kuroda
FUJITSU LIMITED



Attachments:

  [application/octet-stream] v3-0001-doc-Clarify-required-options-for-each-action-in-p.patch (3.1K, ../OSCPR01MB149660CCE2ADCC54A11F57E09F5D92@OSCPR01MB14966.jpnprd01.prod.outlook.com/2-v3-0001-doc-Clarify-required-options-for-each-action-in-p.patch)
  download | inline diff:
From 959222ee6d2f83308324253bcbe3add3466b9533 Mon Sep 17 00:00:00 2001
From: Fujii Masao <[email protected]>
Date: Tue, 18 Mar 2025 10:07:08 +0900
Subject: [PATCH v3 1/2] doc: Clarify required options for each action in
 pg_recvlogical

Each pg_recvlogical action requires specific options. For example,
--slot, --dbname, and --file must be specified with the --start action.
Previously, the documentation did not clearly outline these requirements.

This commit updates the documentation to explicitly state
the necessary options for each action.
---
 doc/src/sgml/ref/pg_recvlogical.sgml | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/ref/pg_recvlogical.sgml b/doc/src/sgml/ref/pg_recvlogical.sgml
index 95eb14b6352..2946bdae1e5 100644
--- a/doc/src/sgml/ref/pg_recvlogical.sgml
+++ b/doc/src/sgml/ref/pg_recvlogical.sgml
@@ -73,6 +73,11 @@ PostgreSQL documentation
         by <option>--dbname</option>.
        </para>
 
+       <para>
+        The <option>--slot</option> and <option>--dbname</option> are required
+        for this action.
+       </para>
+
        <para>
         The <option>--two-phase</option> can be specified with
         <option>--create-slot</option> to enable decoding of prepared transactions.
@@ -87,6 +92,10 @@ PostgreSQL documentation
         Drop the replication slot with the name specified
         by <option>--slot</option>, then exit.
        </para>
+
+       <para>
+        The <option>--slot</option> is required for this action.
+       </para>
       </listitem>
      </varlistentry>
 
@@ -101,6 +110,11 @@ PostgreSQL documentation
         <option>--no-loop</option> is specified.
        </para>
 
+       <para>
+        The <option>--slot</option> and <option>--dbname</option>,
+        <option>--file</option> are required for this action.
+       </para>
+
        <para>
         The stream format is determined by the output plugin specified when
         the slot was created.
@@ -159,6 +173,9 @@ PostgreSQL documentation
         Write received and decoded transaction data into this
         file. Use <literal>-</literal> for <systemitem>stdout</systemitem>.
        </para>
+       <para>
+        This parameter is required for <option>--start</option>.
+       </para>
       </listitem>
      </varlistentry>
 
@@ -265,6 +282,9 @@ PostgreSQL documentation
         mode, create the slot with this name. In <option>--drop-slot</option>
         mode, delete the slot with this name.
        </para>
+       <para>
+        This parameter is required for any of actions.
+       </para>
       </listitem>
      </varlistentry>
 
@@ -305,7 +325,11 @@ PostgreSQL documentation
          The <replaceable>dbname</replaceable> can be a <link
          linkend="libpq-connstring">connection string</link>.  If so,
          connection string parameters will override any conflicting
-         command line options.  Defaults to the user name.
+         command line options.
+        </para>
+        <para>
+         This parameter is required for <option>--create-slot</option>
+         and <option>--start</option>.
         </para>
        </listitem>
       </varlistentry>
-- 
2.43.5



  [application/octet-stream] v3-0002-pg_recvlogical-allow-working-without-dbname-while.patch (1.6K, ../OSCPR01MB149660CCE2ADCC54A11F57E09F5D92@OSCPR01MB14966.jpnprd01.prod.outlook.com/3-v3-0002-pg_recvlogical-allow-working-without-dbname-while.patch)
  download | inline diff:
From 75e0b8649c7370132919e95870cd712bfc33020d Mon Sep 17 00:00:00 2001
From: Hayato Kuroda <[email protected]>
Date: Wed, 19 Mar 2025 11:30:16 +0900
Subject: [PATCH v3 2/2] pg_recvlogical: allow working without --dbname while
 in drop mode

---
 src/bin/pg_basebackup/pg_recvlogical.c        | 3 ++-
 src/bin/pg_basebackup/t/030_pg_recvlogical.pl | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c
index b9ea23e1426..17c64146eff 100644
--- a/src/bin/pg_basebackup/pg_recvlogical.c
+++ b/src/bin/pg_basebackup/pg_recvlogical.c
@@ -945,12 +945,13 @@ main(int argc, char **argv)
 
 	/*
 	 * Run IDENTIFY_SYSTEM to make sure we connected using a database specific
+	 * replication connection. Drop-slot action can work with streaming
 	 * replication connection.
 	 */
 	if (!RunIdentifySystem(conn, NULL, NULL, NULL, &db_name))
 		exit(1);
 
-	if (db_name == NULL)
+	if (!do_drop_slot && db_name == NULL)
 		pg_fatal("could not establish database-specific replication connection");
 
 	/*
diff --git a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
index a6e10600161..62bbc5a3f98 100644
--- a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
+++ b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
@@ -127,4 +127,12 @@ $node->command_ok(
 	],
 	'replayed a two-phase transaction');
 
+$node->command_ok(
+	[
+		'pg_recvlogical',
+		'--slot' => 'test',
+		'--drop-slot'
+	],
+	'drop could work without dbname');
+
 done_testing();
-- 
2.43.5



view thread (20+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: RE: pg_recvlogical requires -d but not described on the documentation
  In-Reply-To: <OSCPR01MB149660CCE2ADCC54A11F57E09F5D92@OSCPR01MB14966.jpnprd01.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox