Skip to content

Tag 13-3.1 doesn't survive container recreate because waldir is missing. #321

Closed
@lucernae

Description

@lucernae

When the container is recreated, it complains that the pg_wal directory is missing.
It turns out that the pg_wal directory inside the PGDATA directory is only a link to whatever directory specified in POSTGRES_INITDB_WALDIR.
I was under the impression that this env POSTGRES_INITDB_WALDIR is only for initializations.
It currently failed upon recreate because POSTGRES_INITDB_WALDIR is outside the default persistent volume.
When the container is recreated, the pg_wal content is lost, which is very dangerous.

Furthermore, if I specified POSTGRES_INITDB_WALDIR into a directory inside the persistent volume, the container is failed to initialize, because in setup-database.sh after directory creation, we deleted using rm -rf ${DATADIR} which caused the initdb waldir to be deleted again. So the postgres init, it failed to find the initdb waldir.

@NyakudyaA do you have any suggestion to fix this?
Is it ok to just move the rm -rf ${DATADIR} up to delete the content before the initdb waldir creation?
From what I understand by default you want the initdb waldir to be outside the default volume. However if initdb waldir is not persisted, when containers are recreated the symlink will not find the directory.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions