Postgres upgrade scripts are being run in an init container. since postgres server is required for dump and restore in different Postgres versions, it is being run in the background in the upgrade scripts using the container's script /usr/bin/run-postgresql.
run-postgresql runs postgres twice, first time for initialization if needed, and second time to actually run the server with the given params.
in some cases the upgrade script identifies postgres as ready in the initialization run, and starts the restore from dump. then if run-postgresql stops the server, the restore fails.
To fix - added 30 sec sleep after pg_isready, to alow for the init phase to complete (usually it should take a few seconds)
Also added error handling and retries in case there are any errors in the dump or restore phases.
Explain the changes
/usr/bin/run-postgresql
.run-postgresql
runs postgres twice, first time for initialization if needed, and second time to actually run the server with the given params.run-postgresql
stops the server, the restore fails.Issues: Fixed #xxx / Gap #xxx
Testing Instructions: