pg_upgrade fails with in-place tablespace

From: "Rui Zhao" <xiyuan(dot)zr(at)alibaba-inc(dot)com>
To: "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: pg_upgrade fails with in-place tablespace
Date: 2023-07-29 15:10:22
Message-ID: 80c80b4a-b87b-456f-bd46-1ae326601d79.xiyuan.zr@alibaba-inc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello postgres hackers,
Recently I encountered an issue: pg_upgrade fails when dealing with in-place tablespace. As we know, pg_upgrade uses pg_dumpall to dump objects and pg_restore to restore them. The problem seems to be that pg_dumpall is dumping in-place tablespace as relative path, which can't be restored.
Here is the error message of pg_upgrade:
psql:/home/postgres/postgresql/src/bin/pg_upgrade/tmp_check/t_002_pg_upgrade_new_node_data/pgdata/pg_upgrade_output.d/20230729T210058.329/dump/pg_upgrade_dump_globals.sql:36: ERROR: tablespace location must be an absolute path
To help reproduce the failure, I have attached a tap test. The test also fails with tablespace regression, and it change the default value of allow_in_place_tablespaces to true only for debug, so it may not be fit for production. However, it is enough to reproduce this failure.
I have also identified a solution for this problem, which I have included in the patch. The solution has two modifications:
1) Make the function pg_tablespace_location returns path "" with in-place tablespace, rather than relative path. Because the path of the in-place tablespace is always 'pg_tblspc/<oid>'.
2) Only check the tablespace with an absolute path in pg_upgrade.
There are also other solutions, such as supporting the creation of relative-path tablespace in function CreateTableSpace. But do we really need relative-path tablespace? I think in-place tablespace is enough by now. My solution may be more lightweight and harmless.
Thank you for your attention to this matter.
Best regards,
Rui Zhao

Attachment Content-Type Size
0001-Fix-pg_upgrade-fails-with-in-place-tablespace.patch application/octet-stream 2.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2023-07-29 15:59:01 Faster "SET search_path"
Previous Message Tomas Vondra 2023-07-29 13:03:31 Re: logical decoding and replication of sequences, take 2