`service postgresql start` exit before actual starts happened

Bug #1826847 reported by ShockwaveNN
8
This bug affects 1 person
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-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

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi,
this is a good bug, sorry to see it so late.
It is actually very similar to bug 1862138.

Let me summarize:
- postgresql.service is actualyl a target, see
  root@x:~# systemctl cat postgresql
  # /lib/systemd/system/postgresql.service
  # 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@9.5-main.service

That worked well through a few tests:
root@x:/# for i in $(seq 1 100); do systemctl restart postgresql@9.5-main.service; sudo -u postgres psql -c "CREATE DATABASE testme$i;"; done

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?

Changed in postgresql-9.5 (Ubuntu):
status: New → Incomplete
Revision history for this message
ShockwaveNN (shockwavenn) wrote :

Oh, this was almos one year ago and as far as I concred my original attached Dockerfile with issue is working fine, so I think issue is solved

on

#dpkg -l | grep postgre
ii postgresql 9.5+173ubuntu0.3 all object-relational SQL database (supported version)
ii postgresql-9.5 9.5.19-0ubuntu0.16.04.1 amd64 object-relational SQL database, version 9.5 server
ii postgresql-client-9.5 9.5.19-0ubuntu0.16.04.1 amd64 front-end programs for PostgreSQL 9.5
ii postgresql-client-common 173ubuntu0.3 all manager for multiple PostgreSQL client versions
ii postgresql-common 173ubuntu0.3 all PostgreSQL database-cluster manager
ii postgresql-contrib-9.5 9.5.19-0ubuntu0.16.04.1 amd64 additional facilities for PostgreSQL

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for postgresql-9.5 (Ubuntu) because there has been no activity for 60 days.]

Changed in postgresql-9.5 (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.