Comment 2 for bug 1973382

Revision history for this message
Dave Jones (waveform) wrote :

Sorry, I'd mis-interpreted this bug! I'd gone digging through the history of debconf and couldn't understand how dpkg-reconfigure was only restarting things just *now*, but hadn't correctly understood that your bug was complaining the service was stopped, but *not started* again. So, my apologies: must read more carefully!

Anyway, to the problem as described: checking d/rules in postgresql-common we find:

# do not (re)start postgresql.service on postgresql-common install/upgrades
override_dh_installinit:
 dh_installinit -ppostgresql-common --name=postgresql -u'defaults 19 21' --no-start
override_dh_installsystemd:
 dh_installsystemd --no-start

This strongly suggests you *do* want to add --no-stop-on-upgrade because the comment indicates a mis-understanding of --no-start. The --no-start option tells dh_install{init,systemd} that you don't want the service automatically started upon installation but in the absence of --no-stop-on-upgrade it *will* still attempt to restart it on upgrades (this isn't terribly well documented in the dh_installsystemd manpage -- I should correct that).

There is one other way you could go about solving this, but it's horribly subtle. The reason preinst is stopping postgres is that --no-start implies --no-restart-after-upgrade, the (terribly named) option that specifies a service *should* be restarted but by stopping it before and upgrade and starting it again afterward (as opposed to --restart-after-upgrade, the usual default which simply runs a restart after an upgrade). Quite *why* --no-start implies --no-restart-after-upgrade I've no idea; I did note it at the time I was hacking on debhelper and it's one of those things that, given free reign, I'd excise. However, as mentioned before I tried to be extremely conservative with my changes to debhelper (and dpkg-reconfigure).

Anyway, the other way you could solve this would be by specifying --no-start and --restart-after-upgrade. This would mean preinst doesn't try to stop the service, but postinst will "try-restart" the service (which means restart if it's already running, but don't start it if it isn't). However, that would run contrary to the comment in d/rules so I suspect it's not what you want to do.

Hope that's not too confusing! Do let me know if there's anything that needs clarification above.