Postgresql server fails to start in recovery with systemd

I ran into an issue while trying to setup a simple test system for myself to move from CentOS 6 to 7. When I was about to start a standby slave systemd reported PostgreSQL startup timeout and stopped it. Although it was running perfectly fine doing recovery.

Issue

In var log message systemd reports failure

Meanwhile in postgresql

Cause

In the systemd script postgresql is being started with -w flag which means ”  -w                     wait until operation complete”. Hence systemd fails after configured timeout.

Fix

Change the -w flag to -W and systemd service file (/usr/lib/systemd/system/postgresql-9.5.service) and reload the daemon.

Hopefully this will save you couple of minutes debugging.

You might like these too

Group by limit per group in PostgreSQL In web applications it's very common to try to limit the results by group. For example showing all the new posts with the the two latest comments on t...
Split or leave frequently updated column in Postgr... I have a database migrated from MySQL to PostgreSQL (I had my good reasons but this post is not about that). In MySQL because of MVCC behaviour it mak...
Postgresql full text search vs Solr Postgresql has really come a long way from being the standard but relatively slow database to the feature rich and extremely fast database what it is ...

About charlesnagy

I'm out of many things mostly automation expert, database specialist, system engineer and software architect with passion towards data, searching it, analyze it, learn from it. I learn by experimenting and this blog is a result of these experiments and some other random thought I have time to time.
Bookmark the permalink.
  • Andrew Dunstan

    That doesn’t seem like a fix. Why did it take more than 300s to start? Did you have only a warm not a hot standby? Incidentally, this really has nothing to do with systemd. The same command could easily fail on a SYSVinit system.