`service postgresql start` exit before actual starts happened

Bug #1826847 reported by ShockwaveNN on 2019-04-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
postgresql-9.5 (Ubuntu)
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-0ubuntu0.16.04.1 amd64 object-relational SQL database, version 9.5 server
ii postgresql-client-9.5 9.5.16-0ubuntu0.16.04.1 amd64 front-end programs for PostgreSQL 9.5
ii postgresql-client-common 173ubuntu0.2 all manager for multiple PostgreSQL client versions
ii postgresql-common 173ubuntu0.2 all PostgreSQL database-cluster manager
ii postgresql-contrib-9.5 9.5.16-0ubuntu0.16.04.1 amd64 additional facilities for PostgreSQL

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers