tianon / docker-postgres-upgrade

a PoC for using "pg_upgrade" inside Docker -- learn from it, adapt it for your needs; don't expect it to work as-is!
https://hub.docker.com/r/tianon/postgres-upgrade/
MIT License
1.04k stars 114 forks source link

"could not create any Unix-domain sockets" #83

Open pat-s opened 10 months ago

pat-s commented 10 months ago

I am trying to update a PG-HA deployed via bitnami in k8s. I have extracted the data as usual. The call looks like

docker run -it -v /tmp/pg-15-16/:/var/lib/postgresql/ tianon/postgres-upgrade:15-to-16 --link

Due to how bitnami creates their structure, I also had to apply the following first:

echo "host all all all md5" > /tmp/pg-15-16/15/data/pg_hba.conf
touch /tmp/pg-15-16/15/data/postgresql.conf

So, so good. However, it fails and inspecting the logs shows:

-----------------------------------------------------------------
  pg_upgrade run on Fri Nov 17 15:56:43 2023
-----------------------------------------------------------------

command: "/usr/lib/postgresql/15/bin/pg_ctl" -w -l "/var/lib/postgresql/16/data/pg_upgrade_output.d/20231117T155643.248/log/pg_upgrade_server.log" -D "/var/lib/postgresql/15/data" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'" start >> "/var/lib/postgresql/16/data/pg_upgrade_output.d/20231117T155643.248/log/pg_upgrade_server.log" 2>&1
waiting for server to start....2023-11-17 15:56:43.404 GMT [106] LOG:  starting PostgreSQL 15.4 (Debian 15.4-2.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2023-11-17 15:56:43.405 GMT [106] LOG:  could not set permissions of file "/var/lib/postgresql/.s.PGSQL.50432": Invalid argument
2023-11-17 15:56:43.405 GMT [106] WARNING:  could not create Unix-domain socket in directory "/var/lib/postgresql"
2023-11-17 15:56:43.406 GMT [106] FATAL:  could not create any Unix-domain sockets
2023-11-17 15:56:43.408 GMT [106] LOG:  database system is shut down
 stopped waiting
pg_ctl: could not start server
Examine the log output.

I can't wrap my head around what's going on. Checked permissions (all owned by postgres), checked no leftovers of other sockets in the data dirs. (NB: using my own arm64 image but also checked with the official tianon image). Any ideas or pointers are welcome!

(Q: Does it make a difference if the data got extracted from a PG-HA instance? It looks identical to a non-HA one on the first look.)

yosifkit commented 10 months ago

Seeing arm64, are you running this on a Mac? I would bet that the filesystem share from macOS to the Docker Desktop VM doesn't support the file type of a Unix socket. Maybe change the config to put the sockets elsewhere in the container like /var/run/postgresql/?

genslein commented 6 months ago

@yosifkit is correct. The new chipsets require that:

docker run --rm \
    -v DIR:/var/lib/postgresql \
    tianon/postgres-upgrade:12-to-15 \
    -c '--socketdir=/var/run/postgresql' \
    --link

I can confirm works. @tianon can you maybe add a little blurb in the README? This should also be fine for alternate chipset distributions that have a hard time with unix socket files.