2

I'm experiencing Postgres service in activating state after incorrect server shutdown. The Postgres seems fine: connections are available and DB is running.

[root@postgres-02 ~]# systemctl status postgresql -l
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/etc/systemd/system/postgresql.service; enabled; vendor preset: disabled)
   Active: activating (start) since Mon 2019-11-04 11:41:26 +08; 4min 38s ago
     Docs: man:postgres(1)
 Main PID: 4882 (postgres)
   CGroup: /system.slice/postgresql.service
           ├─4882 /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
           ├─4884 postgres: checkpointer process
           ├─4885 postgres: writer process
           ├─4886 postgres: wal writer process
           ├─4887 postgres: autovacuum launcher process
           ├─4888 postgres: stats collector process
           ├─4889 postgres: bgworker: logical replication launcher
           ├─4918 postgres: sa30 sa30 192.168.1.3(43566) idle
           ├─4919 postgres: sa30 sa30 192.168.1.3(43568) idle
           ├─4920 postgres: sa30 sa30 192.168.1.3(43570) idle
           ├─4921 postgres: sa30 sa30 192.168.1.3(43572) idle
           ├─4922 postgres: sa30 sa30 192.168.1.3(43574) idle
           └─4934 postgres: sa02 sa02 192.168.1.4(34640) idle
Nov 04 11:41:26 postgres-02.domain systemd[1]: Starting PostgreSQL database server...
Nov 04 11:41:26 postgres-02.domain postgres[4882]: 2019-11-04 11:41:26.652 +08 [4882] LOG:  listening on IPv4 address "192.168.1.10", port 5432
Nov 04 11:41:26 postgres-02.domain postgres[4882]: 2019-11-04 11:41:26.653 +08 [4882] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
Nov 04 11:41:26 postgres-02.domain postgres[4882]: 2019-11-04 11:41:26.892 +08 [4883] LOG:  database system was shut down at 2019-11-04 11:41:09 +08
Nov 04 11:41:26 postgres-02.domain postgres[4882]: 2019-11-04 11:41:26.894 +08 [4882] LOG:  database system is ready to accept connections

It's confusing because of I have other server with similar unit and it runs OK like:

Active: active (running) since

As I understand it's not necessary for ExecStart to spit me out to a shell prompt after executing '/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data', but how systemd understand service is activated.

The unit:

[Unit]
Description=PostgreSQL database server
Documentation=man:postgres(1)

[Service]
Type=notify
User=postgres
ExecStart=/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0

[Install]
WantedBy=multi-user.target

all this stuff is powered by Red Hat Enterprise Linux Server release 7.7

What may we change to achieve the clear 'active' state there?

ps. previous week I did Postgres from source code and faced similar question, but then just rewrote unit to use 'pg_ctl'. in this case configuration seems unchanged, so it confuses me.

1 Answer 1

2

Your unit is of Type=notify, for which, according to the manual

it is expected that the service sends a notification message via sd_notify(3) or an equivalent call when it has finished starting up

Obviously, Postgres will do no such thing, and systemd will never know it's up and running.

On your other servers the unit type is probably simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.