fix: apply the configuration and then start Postgres on the restore stage (#373)
Description
Apply a custom configuration on the restore stage:
- update configs without restarting of Postgres
Related issue
Examples
Initial
2022/08/04 06:44:41 restore.go:167: [INFO] Run job: logicalRestore
2022/08/04 06:44:41 restore.go:182: [INFO] The data directory "/var/lib/dblab/dblab_pool/data" is not empty. Existing data may be overwritten.
2022/08/04 06:44:41 configuration.go:120: [INFO] Configuration is already initialized
2022/08/04 06:44:41 configuration.go:490: [DEBUG] Appending configuration to /var/lib/dblab/dblab_pool/data/postgresql.dblab.postgresql.conf
2022/08/04 06:44:41 tools.go:453: [INFO] Docker image "postgresai/extended-postgres:14" already exists locally
2022/08/04 06:44:41 restore.go:217: [INFO] Running container: dblab_lr_cblmlcohmvjf1tnsgjh0. ID: 87972af8569412bc202f1ae9ef4d022a881d27d46909ceb01c30496b32a9d136
2022/08/04 06:44:41 restore.go:223: [INFO] Waiting for container readiness
2022/08/04 06:44:41 tools.go:336: [INFO] Check container readiness: 87972af8569412bc202f1ae9ef4d022a881d27d46909ceb01c30496b32a9d136
Existing PGDATA
2022/08/04 06:38:25 restore.go:168: [INFO] Run job: logicalRestore
2022/08/04 06:38:25 tools.go:474: [INFO] Docker image "postgresai/extended-postgres:14" already exists locally
2022/08/04 06:38:25 restore.go:225: [INFO] Running container: dblab_lr_cblmif0hmvj9gariom8g. ID: 7ae126ff5c9b617d33fdefba6812e81f9c5e5311daf4dd04366ab26c1a382d6c
2022/08/04 06:38:26 restore.go:231: [INFO] Waiting for container readiness
2022/08/04 06:38:26 tools.go:357: [INFO] Check container readiness: 7ae126ff5c9b617d33fdefba6812e81f9c5e5311daf4dd04366ab26c1a382d6c
2022/08/04 06:38:32 tools.go:258: [DEBUG] Check directory: [ls -A /var/lib/dblab/dblab_pool/data --color=never]
2022/08/04 06:38:32 tools.go:202: [DEBUG] Init db [sh -c su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl initdb -D ${PGDATA}"]
2022/08/04 06:38:33 tools.go:213: [DEBUG] The files belonging to this database system will be owned by user "postgres".
...
2022/08/04 06:38:33 dump.go:516: [DEBUG] Database has been initialized
2022/08/04 06:38:33 configuration.go:204: [DEBUG] Configuring pg_hba.conf...
2022/08/04 06:38:33 configuration.go:228: [DEBUG] Configuring Postgres...
2022/08/04 06:38:33 configuration.go:490: [DEBUG] Appending configuration to /var/lib/dblab/dblab_pool/data/postgresql.dblab.postgresql.conf
2022/08/04 06:38:33 tools.go:275: [DEBUG] Start Postgres
2022/08/04 06:38:33 tools.go:280: [INFO] Starting PostgreSQL instance [sh -c su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D ${PGDATA} -w --timeout 600 start"]
2022/08/04 06:38:33 tools.go:291: [DEBUG] waiting for server to start....2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.pg_control.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.recovery.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.sync.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.promotion.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.snapshot.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.user_defined.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.pg_control.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.recovery.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.sync.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.promotion.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.snapshot.conf"
2022-08-04 06:38:33.701 GMT [67] LOG: skipping missing configuration file "/var/lib/dblab/dblab_pool/data/postgresql.dblab.user_defined.conf"
2022-08-04 06:38:33.713 UTC [67] LOG: redirecting log output to logging collector process
done
server started
2022/08/04 06:38:33 tools.go:293: [DEBUG] Postgres has been started
Checklist
-
MR description has been reviewed -
MR changes are functionally tested -
MR does NOT have text changes OR there are text changes and they have been reviewed -
MR does NOT have API/CLI changes OR there are API/CLI changes and they have been reviewed -
MR does NOT have UI changes OR there are UI changes and they have been reviewed
Closes #373 (closed)
Edited by Artyom Kartasov