]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pg_basebackup: Generate valid temporary slot names under PQbackendPID()
authorMichael Paquier <michael@paquier.xyz>
Thu, 7 Sep 2023 05:12:36 +0000 (14:12 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 7 Sep 2023 05:12:36 +0000 (14:12 +0900)
commitdbd1a06c97f5a2f0c13b05cee1d1ca292ed77f7f
tree0cf23e6e69fb7a4c43b4d548fa9ede03a71945c2
parent69e22dd38faf0641f27544dc06a7ac25b9682533
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
src/bin/pg_basebackup/pg_basebackup.c