pg_basebackup: Always return valid temporary slot names
Jelte Fennema-Nio <me@jeltef.nl>
From: Jelte Fennema <me@jeltef.nl>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Jim Jones <jim.jones@uni-muenster.de>
Date: 2023-08-31T09:13:00Z
Lists: pgsql-hackers
Attachments
- v1-0001-pg_basebackup-Always-return-valid-temporary-slot-.patch (application/octet-stream) patch v1-0001
With PgBouncer in the middle PQbackendPID can return negative values due to it filling all 32 bits of the be_pid with random bits. When this happens it results in pg_basebackup generating an invalid slot name (when no specific slot name is passed in) and thus throwing an error like this: pg_basebackup: error: could not send replication command "CREATE_REPLICATION_SLOT "pg_basebackup_-1201966863" TEMPORARY PHYSICAL ( RESERVE_WAL)": ERROR: replication slot name "pg_basebackup_-1201966863" contains invalid character HINT: Replication slot names may only contain lower case letters, numbers, and the underscore character. This patch fixes that problem by formatting the result from PQbackendPID as an unsigned integer when creating the temporary replication slot name. I think it would be good to backport this fix too. Replication connection support for PgBouncer is not merged yet, but it's pretty much ready: https://github.com/pgbouncer/pgbouncer/pull/876 The reason PgBouncer does not pass on the actual Postgres backend PID is that it doesn't have an associated server connection yet when it needs to send the startup message to the client. It also cannot use it's own PID, because that would be the same for all clients, since pgbouncer is a single process.
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pg_basebackup: Generate valid temporary slot names under PQbackendPID()
- dbd1a06c97f5 11.22 landed
- 2fe968ce9347 12.17 landed
- 6cdd7b805e2b 13.13 landed
- 9de74ca706f6 14.10 landed
- 574bff7bd23c 15.5 landed
- 1057958436c5 16.0 landed
- e1c6db630929 17.0 landed