pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_basebackup: Generate valid temporary slot names under PQbacke
Date: Thu, 07 Sep 2023 05:13:14 +0000
Message-ID: <E1qe7KM-002lpH-Df@gemulon.postgresql.org> (raw)

pg_basebackup: Generate valid temporary slot names under PQbackendPID()

pgbouncer can cause PQbackendPID() to return negative values due to it
filling be_pid with random bytes (even these days pid_max can only be
set up to 2^22 on 64b machines on Linux, for example, so this cannot
happen with normal PID numbers).  When this happens, pg_basebackup may
generate a temporary slot name that may not be accepted by the parser,
leading to spurious failures, like:
pg_basebackup: error: could not send replication command
ERROR:  replication slot name "pg_basebackup_-1201966863" contains
invalid character

This commit fixes that problem by formatting the result from
PQbackendPID() as an unsigned integer when creating the temporary
replication slot name, so as the invalid character is gone and the
command can be parsed.

Author: Jelte Fennema
Reviewed-by: Daniel Gustafsson, Nishant Sharma
Discussion: https://postgr.es/m/CAGECzQQOGvYfp8ziF4fWQ_o8s2K7ppaoWBQnTmdakn3s-4Z=5g@mail.gmail.com
Backpatch-through: 11

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2fe968ce9347c0cff22db7190dc87c795f525dbb

Modified Files
--------------
src/bin/pg_basebackup/pg_basebackup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1qe7KM-002lpH-Df@gemulon.postgresql.org>
Permalink:  ../E1qe7KM-002lpH-Df@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qe7KM-002lpH-Df@gemulon.postgresql.org

 · 

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: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_basebackup: Generate valid temporary slot names under PQbacke
  In-Reply-To: <E1qe7KM-002lpH-Df@gemulon.postgresql.org>

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

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