I am encountering an error when trying to use a tablespace in PolarDB. The tablespace creation works fine, but I get an error when attempting to create a table using the tablespace.
Here’s how to reproduce the issue:
- Use this project to build the image and create a container:
https://github.com/ApsaraDB/polardb-pg-docker-images/
- Create a tablespace directory in the shared data directory:
<code>cd /var/polardb/shared_datadir/pg_tblspc
mkdir abc
</code>
<code>cd /var/polardb/shared_datadir/pg_tblspc
mkdir abc
</code>
cd /var/polardb/shared_datadir/pg_tblspc
mkdir abc
- Create the tablespace successfully:
<code>create tablespace tbs location '/var/polardb/shared_datadir/pg_tblspc/abc';
</code>
<code>create tablespace tbs location '/var/polardb/shared_datadir/pg_tblspc/abc';
</code>
create tablespace tbs location '/var/polardb/shared_datadir/pg_tblspc/abc';
- Attempt to create a table using the tablespace, which results in an error:
<code>postgres=# create table t (id int) tablespace tbs;
ERROR: could not create directory "file-dio:///var/polardb/shared_datadir/pg_tblspc/16388/PG_15_202209061/5": No such file or directory
</code>
<code>postgres=# create table t (id int) tablespace tbs;
ERROR: could not create directory "file-dio:///var/polardb/shared_datadir/pg_tblspc/16388/PG_15_202209061/5": No such file or directory
</code>
postgres=# create table t (id int) tablespace tbs;
ERROR: could not create directory "file-dio:///var/polardb/shared_datadir/pg_tblspc/16388/PG_15_202209061/5": No such file or directory
How can I resolve this issue and successfully create a table in the specified tablespace?