-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Description
A recent change replaced cp -r with cp -l -r to move the new database files into the active directory (in order to save time and disk space), but it breaks upgrades for databases that use tablespaces mounted on a separate Docker volume. Just tried it and had a lot of _Invalid cross-device link errors.
cp: cannot create hard link '/var/lib/postgresql/data/pg_tblspc/16388/PG_17_202406281/16391/38891195' to '/var/lib/postgresql/data/new/pg_tblspc/16388/PG_17_202406281/16391/38891195': Invalid cross-device link cp: cannot create hard link '/var/lib/postgresql/data/pg_tblspc/16388/PG_17_202406281/16391/38891196' to '/var/lib/postgresql/data/new/pg_tblspc/16388/PG_17_202406281/16391/38891196': Invalid cross-device link
Environment
Docker volumes:
Volume 1 mounted at /var/lib/postgresql/data (Primary PGDATA)
Volume 2 mounted at /data/tablespace (Dedicated tablespace volume)
Setup: PostgreSQL has a tablespace created at /data/tablespace. In PGDATA/pg_tblspc/, there is a symlink pointing to this mount.
Example
docker run --rm --name "pgauto" -it
--mount type=bind,source="/path/to/local/postgres-data",target=/var/lib/postgresql/data
--mount type=bind,source="/path/to/local/tablespace-data",target=/data/tablespace
-e POSTGRES_PASSWORD=password
-e PGAUTO_ONESHOT=yes
pgautoupgrade/pgautoupgrade:17-debian
I don't know if the best solution is to revert the change, exclude tablespaces (from what I understand, the files inside the tablespace directory were already upgraded in place by pg_upgrade and only the symlinks themselves need to be moved/created in the root PGDATA, but I am out of my depth here) or try to detect this particular situation and choose to apply -l dynamically.