Does repmgr replicate "CREATE TABLESPACE"?

299 views Asked by At

My standby database was shutdown because the tablespace was not available on the standby server.

error:

2021-06-01 15:16:30.061 EDT [21279] FATAL:  directory "/data/xxx_data_tblsp" does not exist
2021-06-01 15:16:30.061 EDT [21279] HINT:  Create this directory for the tablespace before restarting the server.
2021-06-01 15:16:30.061 EDT [21279] CONTEXT:  WAL redo at 2DDA/8DC6A528 for Tablespace/CREATE: 665042024 "/data/xxx_data_tblsp"

Does repmgr replicate "CREATE TABLESPACE" statement?

If yes, how do I enable it?

software versions:

postgres (PostgreSQL) 10.17 (Ubuntu 10.17-1.pgdg18.04+1)

repmgr --version repmgr 5.2.0

Thanks in advance!

1

There are 1 answers

0
Laurenz Albe On

Repmgr uses PostgreSQL streaming replication, and that replicates everything that is stored in tables. Since tablespaces are stored in pg_catalog.pg_tablespace, they are replicated too.

The problem you encounter is that a tablespace is an object with a component outside the database: the directory where the data are located. You have to create that directory on the file system before you run CREATE TABLESPACE. Now streaming replication will replicate the CREATE TABLESPACE, but it cannot replicate the creation of the directory. It wouldn't make a lot of sense to do that either, since that directory should be in a mounted file system.

Replication is stalled until you create the tablespace directory on the standby server, as the error message tells you.