Thread: BUG #16646: systemctl stop postgresql-12 stuck

BUG #16646: systemctl stop postgresql-12 stuck

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      16646
Logged by:          leo star
Email address:      cs19920509@sina.com
PostgreSQL version: 12.4
Operating system:   centos 8
Description:

i run postgres in docker container.
install step, no particular , follow
'https://www.postgresql.org/download/linux/redhat/'.
no pariticular configuration. no personal data in it. i done nothing. when
it start,  given following output:
--------------------------------------------------------------------------------------------------------------
● postgresql-12.service - PostgreSQL 12 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled;
vendor preset: disabled)
   Active: active (running) since Wed 2020-09-30 06:20:56 UTC; 1s ago
     Docs: https://www.postgresql.org/docs/12/static/
  Process: 2808 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir
${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 2825 (postmaster)
    Tasks: 8 (limit: 25128)
   Memory: 17.1M
   CGroup:
/docker/dceb5f4e11864e1f1becd1826901fa5ab20bf1e171c6f9ea2097e348e3815b04/system.slice/postgresql-12.service
           ├─2825 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
           ├─2834 postgres: logger   
           ├─2836 postgres: checkpointer   
           ├─2837 postgres: background writer   
           ├─2838 postgres: walwriter   
           ├─2839 postgres: autovacuum launcher   
           ├─2840 postgres: stats collector   
           └─2841 postgres: logical replication launcher   

9月 30 06:20:56 dceb5f4e1186 systemd[1]: Starting PostgreSQL 12 database
server...
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.081 UTC
[2825] LOG:  starting PostgreSQL 12.4 on x86_64-pc-linux-gnu, compiled by
gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.085 UTC
[2825] LOG:  listening on IPv4 address "127.0.0.1", port 5432
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.085 UTC
[2825] LOG:  could not bind IPv6 address "::1": Cannot assign requested
address
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.085 UTC
[2825] HINT:  Is another postmaster already running on port 5432? If not,
wait a few seconds and retry.
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.086 UTC
[2825] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.087 UTC
[2825] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.097 UTC
[2825] LOG:  redirecting log output to logging collector process
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.097 UTC
[2825] HINT:  Future log output will appear in directory "log".
9月 30 06:20:56 dceb5f4e1186 systemd[1]: Started PostgreSQL 12 database
server.
--------------------------------------------------------------------------------------------------------------
when i stop postgres, it stuck. i kill it and give a timeout to
postgresql-12.service. restart it. it returned finally with failed. the
following sentence is when timeout systemd output:
--------------------------------------------------------------------------------------------------------------
● postgresql-12.service - PostgreSQL 12 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled;
vendor preset: disabled)
   Active: failed (Result: timeout) since Wed 2020-09-30 06:21:09 UTC; 2s
ago
     Docs: https://www.postgresql.org/docs/12/static/
  Process: 2825 ExecStart=/usr/pgsql-12/bin/postmaster -D ${PGDATA}
(code=exited, status=0/SUCCESS)
  Process: 2808 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir
${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 2825 (code=exited, status=0/SUCCESS)

9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.086 UTC
[2825] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.087 UTC
[2825] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.097 UTC
[2825] LOG:  redirecting log output to logging collector process
9月 30 06:20:56 dceb5f4e1186 postmaster[2825]: 2020-09-30 06:20:56.097 UTC
[2825] HINT:  Future log output will appear in directory "log".
9月 30 06:20:56 dceb5f4e1186 systemd[1]: Started PostgreSQL 12 database
server.
9月 30 06:21:06 dceb5f4e1186 systemd[1]: Stopping PostgreSQL 12 database
server...
9月 30 06:21:06 dceb5f4e1186 systemd[1]: postgresql-12.service: Killing
process 2834 (postmaster) with signal SIGKILL.
9月 30 06:21:09 dceb5f4e1186 systemd[1]: postgresql-12.service: Processes
still around after final SIGKILL. Entering failed mode.
9月 30 06:21:09 dceb5f4e1186 systemd[1]: postgresql-12.service: Failed with
result 'timeout'.
9月 30 06:21:09 dceb5f4e1186 systemd[1]: Stopped PostgreSQL 12 database
server.
--------------------------------------------------------------------------------------------------------------
as you can see only a '2834 postgres: logger' can not stop result in stuck.
it tried many times. the reason is logger.