`service postgresql start` exit before actual starts happened
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
postgresql-9.5 (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
I used this Dockerfile to reproduce this problem:
```
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y postgresql sudo
RUN service postgresql start && \
sudo -u postgres psql -c "CREATE DATABASE test1;"
RUN service postgresql start && \
sudo -u postgres psql -c "CREATE DATABASE test2;"
```
When second `service postgresql start` performed I got and error:
```
psql: FATAL: the database system is starting up
The command '/bin/sh -c service postgresql start && sudo -u postgres psql -c "CREATE DATABASE test;"' returned a non-zero code: 2
```
But if I add some timeout after start command everything is fine
```
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y postgresql sudo
RUN service postgresql start && \
sudo -u postgres psql -c "CREATE DATABASE test1;"
RUN service postgresql start && \
sleep 30 && \
sudo -u postgres psql -c "CREATE DATABASE test2;"
```
Versions are:
dpkg -l | grep postgre
ii postgresql 9.5+173ubuntu0.2 all object-relational SQL database (supported version)
ii postgresql-9.5 9.5.16-
ii postgresql-
ii postgresql-
ii postgresql-common 173ubuntu0.2 all PostgreSQL database-cluster manager
ii postgresql-
Hi,
this is a good bug, sorry to see it so late.
It is actually very similar to bug 1862138.
Let me summarize: system/ postgresql. service 9.5-main. service
- postgresql.service is actualyl a target, see
root@x:~# systemctl cat postgresql
# /lib/systemd/
# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded.
- the individual clusters are usually synchronous, so if you need that behavior
you'd need (for the default, or another name if you have others)
$ systemctl start postgresql@
That worked well through a few tests: 9.5-main. service; sudo -u postgres psql -c "CREATE DATABASE testme$i;"; done
root@x:/# for i in $(seq 1 100); do systemctl restart postgresql@
I'd expect those to aso work on the docker example, but I have to admit I was generally only barely able to trigger the issue in my (LXD) containers.
P.S. Maybe after it is the general bad integration of system services in docker?