Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore of db from WAL is impossible if public schema does not exists #1022

Open
jovanradin opened this issue Aug 26, 2024 · 1 comment
Open

Comments

@jovanradin
Copy link

I'm using ghcr.io/zalando/spilo-15:3.2-p1 (tried also with other versions) and when i try to restore db from WAL backup i have following error:

ERROR:  schema "public" does not exist
2024-08-23 13:28:47,420 ERROR: post_init script /scripts/post_init.sh "zalandos" returned non-zero code 3
2024-08-23 13:28:47,421 INFO: removing initialize key after failed attempt to bootstrap the cluster
2024-08-23 13:28:47,459 INFO: renaming data directory to /home/postgres/pgdata/pgroot/data.failed
Traceback (most recent call last):
  File "/usr/local/bin/patroni", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/patroni/__main__.py", line 344, in main
    return patroni_main(args.configfile)
  File "/usr/local/lib/python3.10/dist-packages/patroni/__main__.py", line 232, in patroni_main
    abstract_main(Patroni, configfile)
  File "/usr/local/lib/python3.10/dist-packages/patroni/daemon.py", line 174, in abstract_main
    controller.run()
  File "/usr/local/lib/python3.10/dist-packages/patroni/__main__.py", line 192, in run
    super(Patroni, self).run()
  File "/usr/local/lib/python3.10/dist-packages/patroni/daemon.py", line 143, in run
    self._run_cycle()
  File "/usr/local/lib/python3.10/dist-packages/patroni/__main__.py", line 201, in _run_cycle
    logger.info(self.ha.run_cycle())
  File "/usr/local/lib/python3.10/dist-packages/patroni/ha.py", line 1972, in run_cycle
    info = self._run_cycle()
  File "/usr/local/lib/python3.10/dist-packages/patroni/ha.py", line 1786, in _run_cycle
    return self.post_bootstrap()
  File "/usr/local/lib/python3.10/dist-packages/patroni/ha.py", line 1670, in post_bootstrap
    self.cancel_initialization()
  File "/usr/local/lib/python3.10/dist-packages/patroni/ha.py", line 1663, in cancel_initialization
    raise PatroniFatalException('Failed to bootstrap cluster')
patroni.exceptions.PatroniFatalException: Failed to bootstrap cluster

We probably just need:

CREATE SCHEMA IF NOT EXISTS public

In post_init.sh to successfully add extensions etc

Also if anyone knows solution how i can restore db without creating my own docker image, please help :)

@jovanradin
Copy link
Author

I just changed create_user_functions.sql, added CREATE SCHEMA IF NOT EXISTS public; and with custom docker image restore now works.
Still think that this should be added in official containers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant