Re: Have pg_basebackup write "dbname" in "primary_conninfo"?

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: robertmhaas(at)gmail(dot)com
Cc: kuroda(dot)hayato(at)fujitsu(dot)com, barwick(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Have pg_basebackup write "dbname" in "primary_conninfo"?
Date: 2024-02-21 03:04:24
Message-ID: 20240221.120424.79274783106518358.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Tue, 20 Feb 2024 19:56:10 +0530, Robert Haas <robertmhaas(at)gmail(dot)com> wrote in
> It seems like maybe somebody should look into why this is happening,
> and perhaps fix it.

GetConnection()@streamutil.c wants to ensure conninfo has a fallback
database name ("replication"). However, the function seems to be
ignoring the case where neither dbname nor connection string is given,
which is the first case Kuroda-san raised. The second case is the
intended behavior of the function.

> /* pg_recvlogical uses dbname only; others use connection_string only. */
> Assert(dbname == NULL || connection_string == NULL);

And the function incorrectly assumes that the connection string
requires "dbname=replication".

> * Merge the connection info inputs given in form of connection string,
> * options and default values (dbname=replication, replication=true, etc.)

But the name is a pseudo database name only used by pg_hba.conf
(maybe) , which cannot be used as an actual database name (without
quotation marks, or unless it is actually created). The function
should not add the fallback database name because the connection
string for physical replication connection doesn't require the dbname
parameter. (attached patch)

About the proposed patch, pg_basebackup cannot verify the validity of
the dbname. It could be problematic.

Although I haven't looked the original thread, it seems that the
dbname is used only by pg_sync_replication_slots(). If it is true,
couldn't we make the SQL function require a database name to make a
connection, instead of requiring it in physical-replication conninfo?

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
do_not_set_fallback_dbname.txt text/plain 969 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2024-02-21 03:27:46 'Shutdown <= SmartShutdown' check while launching processes in postmaster.
Previous Message Hayato Kuroda (Fujitsu) 2024-02-21 02:15:57 RE: Have pg_basebackup write "dbname" in "primary_conninfo"?