I installed PostgreSQL server on a fresh install of openSuse 13.2 (KDE).
I was able to start the PostgreSQL service. I enabled the service using
systemctl enable postgresql.service
The postgresql service starts successfully after booting the system.
However if I shutdown the system, the PostgreSQL process is killed before the postgres init script is called. Therefore the postgres database is not closed properly and an auto recovery of the database is started when the service is started the next time. This is probably not a reliable solution.
Can someone confirm that this is general problem?
Not specific to PostgreSQL, I can verify that what you’ve observed is generally true of openSUSE ever since systemd was implemented when shutting down… I’ve also seen all sorts of services and processes killed unceremoniously and suddenly instead of gracefully shutting down. The advantage of course is that people are impressed how quickly you can subsequently power off and leave instead of watching and waiting… waiting for a machine to shut down.
I haven’t investigated recently but when I looked into this more than a year ago, the most common recommendation (I considered imperfect) was to increase the time counter(delay) for shutting down. The idea is that you either guess or determine how long it takes for your affected service (PostgreSQL in your case) to shut down, and then set the appropriate value for system shutdown.
To me, that still left much to chance and also might require setting the delay unnecessarily (or necessarily) high to ensure the service(s) shut down. Probably a more elegant solution would be to do something like script inspecting service status, and system shutdown only when all others have shut down. But, to do this correctly might require some thought and experimentation. Maybe a simpler solution is to create a custom shutdown script which first stops the PostgreSQL service before invoking system shutdown. You could even do this by creating a custom Unit file which requires services to stop before executing shutdown.
But looking at this today,
I’d recommend you read the MAN pages for
In the following, describes the default timeout settings system-wide and although may not be immediately relevant the watchdog timer defaults (when you start messing with settings, you may want to know the settings that limit when your modification causes unexpected results)
Note also in the above that describes system-wide timeouts, that service specific settings can be made in the service Unit files and references the following MAN page
If you resolve your issue, be sure to post your results here again…
As I described, the default system behavior is probably OK for most non-Server (or even Server) configurations, but when running a large database, it’s probably not a good idea to shutdown before all your atomic transactions have been verified executed.