helvalius/nominatim-docker

Building error: psql: FATAL: the database system is starting up

PatriQ7 opened this issue · 5 comments

When I was building image in Step 25:
RUN sudo service postgresql start && sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -u postgres createuser -s nominatim && sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data && sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim"

I got this error message:

 ---> Running in 0af981cb65f6
 * Starting PostgreSQL 9.3 database server
   ...done.
psql: FATAL:  the database system is starting up
createuser: could not connect to database postgres: FATAL:  the database system is starting up
createuser: could not connect to database postgres: FATAL:  the database system is starting up
The command '/bin/sh -c sudo service postgresql start &&   sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='nominatim'" | grep -q 1 || sudo -u postgres createuser -s nominatim &&   sudo -u postgres psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='www-data'" | grep -q 1 || sudo -u postgres createuser -SDR www-data &&   sudo -u postgres psql postgres -c "DROP DATABASE IF EXISTS nominatim"' returned a non-zero code: 1

Hi,

I couldn't verify this with the latest commit. Could you please try to verify if this issue persists with the latest commit?

Thanks!

I get the same error (latest commit). Postgres does not seem to start up fully, despite saying so:

Step 28 : RUN service postgresql start &&   sudo -u nominatim ./utils/setup.php --osm-file /app/data.pbf --all --threads 2
 ---> Running in dfa609f7422f
 * Starting PostgreSQL 9.3 database server
   ...done.
Create DB
createdb: could not connect to database template1: FATAL:  the database system is starting up
ERROR: Error executing external command: createdb -E UTF-8 -p 5432 nominatim

Given that postgres shouldn't say "done" before it's actually ready, I assume the timing issue can be solved consistently by inserting a short delay before starting nominatim. The following change works for me:

RUN service postgresql start && sleep 10 &&   sudo -u nominatim ./utils/setup.php --osm-file /app/data.pbf --all --threads 2

@PatriQ7 @helvalius @jkgeyti it occurse because service postgres start but not service postgres stop.

I'm wrote new Dockerfile and it 100% works. Happy to help.
https://github.com/cartography/nominatim-docker

divlv commented

@winsento I've got exactly the same situation -
"pg_connect(): Unable to connect to PostgreSQL server: FATAL: the database system is starting up"
but when I'm starting the build image.
Neither docker run... nor docker start...
Can't connect with the error, mentioned above.

Any suggestions?

I have cloned the latest version and I am getting this error at build:

createdb: could not connect to database template1: FATAL:  the database system is starting up
ERROR: Error executing external command: createdb -E UTF-8 -p 5432 nominatim
Error executing external command: createdb -E UTF-8 -p 5432 nominatim
The command '/bin/sh -c sudo -u postgres /usr/lib/postgresql/9.3/bin/pg_ctl start -w -D /etc/postgresql/9.3/main/ &&   sudo -u nominatim ./utils/setup.php --osm-file /app/data.pbf --all --threads 2' returned a non-zero code: 255