[Pkg-postgresql-public] Bug#759725: #759725: postgresql-common: non-synchronous service postgresql start/stop/reload

beuc at debian.org beuc at debian.org
Wed Mar 11 16:44:34 UTC 2015


Hi,

I currently get a race condition when stopping postgresql and backing
up /var/lib/postgresql.  We use this backup to quickly reset the DB to
a saved state in a lenghty testsuite.

cp: cannot stat '/var/lib/postgresql/9.4/main/postmaster.pid': No such file or directory

In other words, the init system tells me postgresql is properly down,
I even have additional tests in my script to try and connect to the DB
to ensure the service is actually down, but really the service is
still up, and the .pid file is eventually removed in the background by
the init system, during the 'cp'.

Can you make the 'stop' procedure synchronous as well ?

- Sylvain


On Wed, Oct 08, 2014 at 12:04:33PM +0200, beuc at debian.org wrote:
> Hi,
> 
> Thanks for the recent patch.
> 
> - It fixes 'start' and 'restart'.
>   I'm not sure about 'reload' but I couldn't make it fail, so OK :)
> 
> - However 'stop' is not fixed (still async).
> 
> - Also after
>   service postgresql stop ; rm -rf /var/lib/postgresql ; service postgresql start
>   -> 'status' will still happily declare the service 'active'
> 
> These tests show the bug is not completely fixed, so I'm reopening it.
> 
> Cheers!
> Sylvain
> 
> On Tue, Oct 07, 2014 at 07:39:19PM +0000, Debian Bug Tracking System wrote:
> > This is an automatic notification regarding your Bug report
> > which was filed against the postgresql-common package:
> > 
> > #759725: postgresql-common: non-synchronous service postgresql start/stop/reload
> > 
> > It has been closed by Christoph Berg <myon at debian.org>.
> > 
> > Their explanation is attached below along with your original report.
> > If this explanation is unsatisfactory and you have not received a
> > better one in a separate message then please contact Christoph Berg <myon at debian.org> by
> > replying to this email.
> > 
> > 
> > -- 
> > 759725: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759725
> > Debian Bug Tracking System
> > Contact owner at bugs.debian.org with problems
> 
> > Date: Tue, 07 Oct 2014 19:34:49 +0000
> > From: Christoph Berg <myon at debian.org>
> > To: 759725-close at bugs.debian.org
> > Subject: Bug#759725: fixed in postgresql-common 162
> > 
> > Source: postgresql-common
> > Source-Version: 162
> > 
> > We believe that the bug you reported is fixed in the latest version of
> > postgresql-common, which is due to be installed in the Debian FTP archive.
> > 
> > A summary of the changes between this version and the previous one is
> > attached.
> > 
> > Thank you for reporting the bug, which will now be closed.  If you
> > have further comments please address them to 759725 at bugs.debian.org,
> > and the maintainer will reopen the bug report if appropriate.
> > 
> > Debian distribution maintenance software
> > pp.
> > Christoph Berg <myon at debian.org> (supplier of updated postgresql-common package)
> > 
> > (This message was generated automatically at their request; if you
> > believe that there is a problem with it please contact the archive
> > administrators by mailing ftpmaster at ftp-master.debian.org)
> > 
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA256
> > 
> > Format: 1.8
> > Date: Tue, 07 Oct 2014 21:25:25 +0200
> > Source: postgresql-common
> > Binary: postgresql-common postgresql-client-common postgresql-server-dev-all postgresql postgresql-client postgresql-doc postgresql-contrib
> > Architecture: source all
> > Version: 162
> > Distribution: unstable
> > Urgency: medium
> > Maintainer: Debian PostgreSQL Maintainers <pkg-postgresql-public at lists.alioth.debian.org>
> > Changed-By: Christoph Berg <myon at debian.org>
> > Description:
> >  postgresql - object-relational SQL database (supported version)
> >  postgresql-client - front-end programs for PostgreSQL (supported version)
> >  postgresql-client-common - manager for multiple PostgreSQL client versions
> >  postgresql-common - PostgreSQL database-cluster manager
> >  postgresql-contrib - additional facilities for PostgreSQL (supported version)
> >  postgresql-doc - documentation for the PostgreSQL database management system
> >  postgresql-server-dev-all - extension build tool for multiple PostgreSQL versions
> > Closes: 759725 761020 762632
> > Changes:
> >  postgresql-common (162) unstable; urgency=medium
> >  .
> >    [ Christoph Berg ]
> >    * Move PgCommon.pm to /usr/share/perl5.
> >    * t/020_create_sql_remove.t: Test psql -tx alignment to catch a bug in
> >      9.4beta2.
> >    * supported-versions: Set 9.4 as pgdg default on Ubuntu 14.10.
> >    * Debconf translation updates, thanks!
> >      + nl by Frans Spiesschaert. (Closes: #762632)
> >  .
> >    [ Peter Michael Green ]
> >    * Use ID_LIKE to identify deriviatives of Debian and Ubuntu.
> >      (Closes: #761020)
> >  .
> >    [ Richard Hughes ]
> >    * Use Type=forking in postgresql at .service and start before postgresql.
> >      (Closes: #759725)
> > Checksums-Sha1:
> >  d16d77dcd70a0e5d3c39795089894f6b336605ee 2240 postgresql-common_162.dsc
> >  72700311d17f9f5b0ab33dac3c2ee4b1f691a83e 186148 postgresql-common_162.tar.xz
> >  f1d9c51af5a8d18e3ff2f93911a2b66702e3eef8 58446 postgresql-server-dev-all_162_all.deb
> >  c5aa9355d15073352377250fc34fe71f8676f846 51340 postgresql_9.4+162_all.deb
> >  890006a4d530ef8b80d061bc4042e6cd798a3f00 51360 postgresql-client_9.4+162_all.deb
> >  34b2d39d1f6022cd96876f9b97ad987afee38ff9 51350 postgresql-doc_9.4+162_all.deb
> >  8ee08a4781b7e6a4b8e02dcd61fccf1313754fdf 51348 postgresql-contrib_9.4+162_all.deb
> >  37cdc985a272f14601430965e0a4b0c51077945b 200776 postgresql-common_162_all.deb
> >  4fd33e920efd5753e91b33bf9c616e3934b56534 72972 postgresql-client-common_162_all.deb
> > Checksums-Sha256:
> >  60ad532f39e13d151ef7f1fcd41c827c881db8a6930bdf293cb6bc7e895aab8b 2240 postgresql-common_162.dsc
> >  b5346242d7c3704002d6ca9f1339cdd029a7835ef91edadeb33c78efe3b4b96b 186148 postgresql-common_162.tar.xz
> >  a8ae6a6a98bbf55e6ce7bda3ad9f80d72b74363b0178d450daeaeac1e746c62c 58446 postgresql-server-dev-all_162_all.deb
> >  e4fa20fae0095a92b18673edc31f26c93b8dddecb4a5f0dfdea3ab661d29173e 51340 postgresql_9.4+162_all.deb
> >  58c7da68cf06e36cdd98442a937c671278d5f6f8cdd24a062c2b80a05966f315 51360 postgresql-client_9.4+162_all.deb
> >  3f2078e2beeb6d8ad9155415772fd650a85852a502cc3a8d9e360bcbcbc3b089 51350 postgresql-doc_9.4+162_all.deb
> >  3234f193a5a1645c56f860776a1ab9420d0e0eff932864ad93776d1bcf60db63 51348 postgresql-contrib_9.4+162_all.deb
> >  aac562a550a831661d477b20cbe43510fadb699fdcc330a50b6ca71e510ddbb6 200776 postgresql-common_162_all.deb
> >  fd0ec54bdab7318795134ec98bba6127c656fe38efefe3d8a52f1241e203a79b 72972 postgresql-client-common_162_all.deb
> > Files:
> >  abfe957bd81f3d68aec0205233ff609e 58446 database optional postgresql-server-dev-all_162_all.deb
> >  9c3efc223baa8258cad326470d523b74 51340 database optional postgresql_9.4+162_all.deb
> >  d5bc60b95fbee06b77f930ce66425ec9 51360 database optional postgresql-client_9.4+162_all.deb
> >  5b651fecba32a54ab5b316a168f72b66 51350 doc optional postgresql-doc_9.4+162_all.deb
> >  fc840fdb116d0081c38d157e85d8f073 51348 database optional postgresql-contrib_9.4+162_all.deb
> >  3d6c3f20e3e1a91bfb2ad1ad3461f617 200776 database optional postgresql-common_162_all.deb
> >  bdd30524c1444521f3eb9db7823153cd 72972 database optional postgresql-client-common_162_all.deb
> >  62e59e4d5652fe62dd9b836d0e78c901 2240 database optional postgresql-common_162.dsc
> >  9c6f016609e8a4f74228b3f024d7f5c2 186148 database optional postgresql-common_162.tar.xz
> > 
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1
> > 
> > iQIcBAEBCAAGBQJUND53AAoJEExaa6sS0qeudI4P/26SGgCyyzCpp9td6F2hlLwF
> > /pNLvS87A0fNlKz6GzRbd9osKxLe9SWteZwKdgjYtUzeCvr8awQLrLNdpLtzg6ru
> > VJZWyiA/ixX8KEIXL1Ze5EfnDCdxyS5keTmzZG/mmoyzH4qeAeTMcLYQc38r4w2o
> > VXB6wgizt4Ua4mzKLOU7OlhfwfAY9e5VQjEDoYpsJ24Xdt8kLTD8tXkn1HgeajO7
> > GCKrU0YLkd9Q2aj9B1+qtMYwTf7PLqH1Lzu+Fwg+2mee14bo22cMecROmSKV7yFp
> > BtlNCEtBV1z1AHHrK0kzwzsME4BzKbXNxKoSA35YWzll/DOIeO3uUMDitHVIK/AL
> > pyK7pMyeUkdyHHKFJ+YriUelX3Q1yMePxZqp6O541LkWje5aA/8ZTZjyLGbHhQ/5
> > /w4cJVHAO3rG4hByc6pAXCrtJOjNFYGewHb+oc8mTdbEHRbPK+aRgC2ugDN8+JKA
> > xNVTfykF/0vdPH6+Qsm0deQDgHuHkx58jawivjaSuoVKsCKCmKjGH46CzuLfqfkK
> > +Upr8oX0lCJFfgGapVKySjk31BRAFmGicnTzYCSzWwXFOkaoTQydzUJ4gYug5pfK
> > mQGGLz3J9RiSJaAyF5BOAfespx9PnAz2H24gb7iPazfzxWm31WIz+mzt00F09UCg
> > ukCm6ezkAR8adS0f/lqH
> > =vmXR
> > -----END PGP SIGNATURE-----
> 
> > Date: Fri, 29 Aug 2014 20:28:50 +0200
> > From: beuc <beuc at debian.org>
> > To: Debian Bug Tracking System <submit at bugs.debian.org>
> > Subject: postgresql-common: non-synchronous service postgresql
> >  start/stop/reload
> > X-Mailer: reportbug 6.5.0
> > 
> > Package: postgresql-common
> > Version: 160
> > Severity: important
> > 
> > Hi,
> > 
> > When working on the FusionForge installation system today I noticed
> > that in Debian Jessie, running:
> > 
> >   service postgresql start
> > 
> > (or stop, or reload), is now asynchronous, due to using the new
> > PostgreSQL systemd init scripts.
> > 
> > Previously I could rely on the init script to come back when the
> > database was properly stopped and flushed.  Right now the command
> > returns immediately and starts/stops/reloads in the background.
> > 
> > My scripts need to modify the PostgreSQL listen address and reload it
> > before populating the database through the PHP application.  They also
> > need to stop/backup/start the server for quick load/restore during our
> > testsuite.  Due to this change the installation system fails randomly
> > due to race condition.
> > 
> > I found it basically impossible to work-around this issue in a
> > portable manner:
> > 
> > - 'service postgresql status' is not reliable: it usually says the
> >   service is stopped far before the shutdown is complete. I also got a
> >   few cases where it reported active service with no running daemon.
> > 
> > - the 'postgresql' process may be stopped already, but pg_ctl still
> >   doing a faststop (especially when there's data to flush to disk) -
> >   there may also be other PostgreSQL processes I don't know about;
> >   so 'ps' is not reliable either.
> > 
> > - the postgresql control commands vary between Debian and RedHat
> >   (pg_ctl vs. pg_clusterctl), and they need a data directory that can
> >   be in varied, possibly multiple, locations. Using 'pg_*ctl' manually
> >   is error-prone and long.
> > 
> > - in any case that will require fare more code and testing than
> >   'service postgresql xxx'
> > 
> > Please consider maintaining 'service postgresql start/stop/reload'
> > synchronous even with systemd.
> > 
> > Cheers!
> > Sylvain
> > 
> > 
> > -- System Information:
> > Debian Release: jessie/sid
> >   APT prefers testing-updates
> >   APT policy: (500, 'testing-updates'), (500, 'testing')
> > Architecture: amd64 (x86_64)
> > Foreign Architectures: i386
> > 
> > Kernel: Linux 3.14-2-amd64 (SMP w/8 CPU cores)
> > Locale: LANG=eo.UTF-8, LC_CTYPE=eo.UTF-8 (charmap=UTF-8)
> > Shell: /bin/sh linked to /bin/dash
> > 
> > Versions of packages postgresql-common depends on:
> > ii  adduser                   3.113+nmu3
> > ii  debconf [debconf-2.0]     1.5.53
> > ii  init-system-helpers       1.21
> > ii  lsb-base                  4.1+Debian13
> > ii  postgresql-client-common  160
> > ii  procps                    1:3.3.9-7
> > ii  ssl-cert                  1.0.34
> > ii  ucf                       3.0030
> > 
> > Versions of packages postgresql-common recommends:
> > ii  logrotate  3.8.7-1
> > 
> > postgresql-common suggests no packages.
> > 
> > -- debconf information excluded
> 



More information about the Pkg-postgresql-public mailing list