Thread: BUG #14320: systemd terminates postgresql hot standby instance 90 seconds after start

BUG #14320: systemd terminates postgresql hot standby instance 90 seconds after start

From
andreas.papst@univie.ac.at
Date:
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz
aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDMyMApMb2dnZWQgYnk6ICAg
ICAgICAgIEFuZHJlYXMgUGFwc3QKRW1haWwgYWRkcmVzczogICAgICBhbmRy
ZWFzLnBhcHN0QHVuaXZpZS5hYy5hdApQb3N0Z3JlU1FMIHZlcnNpb246IDku
NC45Ck9wZXJhdGluZyBzeXN0ZW06ICAgRGViaWFuIEdOVS9MaW51eCA4LjUg
KGplc3NpZSkKRGVzY3JpcHRpb246ICAgICAgICAKCkhleSwNCg0Kd2hlbiBz
dGFydGluZyBhIGhvdCBzdGFuZGJ5IGRhdGFiYXNlIGluc3N0YW5jZSB3aXRo
IA0KYHN5c3RlbWN0bCBzdGFydCBwb3N0Z3Jlc3FsJywgDQphbnl0aGluZyB3
b3JrcyBwZXJmZWN0OiBXQUwgZmlsZXMgYXJlIGJlZWluZyBhcHBsaWVkLCBy
L28gY29ubmVjdGlvbnMgYXJlCmFibGUgdG8gcXVlcnkgdGhlIGRhdGFiYXNl
LCBidXQgYWZ0ZXIgOTAgc2Vjb25kcyAoc3lzdGVtZApEZWZhdWx0VGltZW91
dFN0YXJ0U2VjKSBwb3N0Z3Jlc3FsIGlzIGJlZWluZyBzaHV0IGRvd246DQoy
MDE2LTA5LTAxIDEwOjMwOjE1LjIzNSBDRVNUIEAgKC8yNjY3MSkgTE9HOiAg
cmVjZWl2ZWQgc21hcnQgc2h1dGRvd24KcmVxdWVzdA0KMjAxNi0wOS0wMSAx
MDozMDoxNS4zMzAgQ0VTVCBAICgvMjY2OTkpIEZBVEFMOiAgdGVybWluYXRp
bmcgd2FscmVjZWl2ZXIKcHJvY2VzcyANCmR1ZSB0byBhZG1pbmlzdHJhdG9y
IGNvbW1hbmQNCjIwMTYtMDktMDEgMTA6MzA6MTYuOTY3IENFU1QgQCAoLzI2
Njc1KSBMT0c6ICBzaHV0dGluZyBkb3duDQoyMDE2LTA5LTAxIDEwOjMwOjE3
Ljc0OCBDRVNUIEAgKC8yNjY3NSkgTE9HOiAgZGF0YWJhc2Ugc3lzdGVtIGlz
IHNodXQgZG93bg0KDQphbmQgdGhlIHN5c3RlbWN0bCBzdGFydCBjb21tYW5k
IHJldHVybnMgdG9vLg0KDQpJIGd1ZXNzIHRoaXMgaXMgZHVlIHRvIGEgbWlz
c2luZyBzdGVwIGluIHN0YXJ0aW5nIHVwIHBvc3RncmVzcWwgaW4gaG90CnN0
YW5kYnkgY29uZmlndXJhdGlvbiwgd2hlcmUgdGhpcyBwcm9jZXNzICBzaG91
bGQgYmUgZGV0YWNoZWQvZGFlbW9uaXplZAooY2FsbGluZyBzZXRzaWQpLg0K
DQpUbyBwcm9vZiBpdCwgSSBzZW50IGEgc2lnbmFsIHdpdGgNCmBzeXN0ZW1j
dGwgcmVsb2FkIHBvc3RncmVzcWzCtCB3aGljaCBjYXVzZWQgdGhlIHN5c3Rl
bWN0bCBzdGFydCBjb21tYW5kIHRvCmZpbmlzaCBhbmQga2VwdCBwb3N0Z3Jl
c3FsIHJ1bm5pbmcuDQoNCkkndmUgdHJpZWQgdG8gZmluZCB0aGUgcmVzcGVj
dGl2ZSBsaW5lcyBpbiB0aGUgY29kZSBidXQgSSB0b3RhbGx5IGdldCBsb3N0
LgpTbyBwbGVhc2UgaWYgc29tZWJvZHkgY2FuIGZpeCBpdC4NCg0KVGhhbmsg
eW91Cgo=
On 9/9/16 6:50 AM, andreas.papst@univie.ac.at wrote:
> when starting a hot standby database insstance with
> `systemctl start postgresql',
> anything works perfect: WAL files are beeing applied, r/o connections are
> able to query the database, but after 90 seconds (systemd
> DefaultTimeoutStartSec) postgresql is beeing shut down:

This is all quite plausible, but it depends on how your systemd service
for postgresql is configured.  So please post that if you want us to
analyze it.

--
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Hey Peter,

thank you for your offer.

# cat /etc/debian_version
8.5
# dpkg -l | grep postgres
-------------------------------------------------------------------
ii  pgdg-keyring                      2014.1                         all
         keyring for apt.postgresql.org
ii  postgresql-9.4                    9.4.9-1.pgdg80+1
amd64        object-relational SQL database, version 9.4 server
ii  postgresql-9.5                    9.5.4-1.pgdg80+1
amd64        object-relational SQL database, version 9.5 server
ii  postgresql-client-9.4             9.4.9-1.pgdg80+1
amd64        front-end programs for PostgreSQL 9.4
ii  postgresql-client-9.5             9.5.4-1.pgdg80+1
amd64        front-end programs for PostgreSQL 9.5
ii  postgresql-client-common          175.pgdg80+1                   all
         manager for multiple PostgreSQL client versions
ii  postgresql-common                 175.pgdg80+1                   all
         PostgreSQL database-cluster manager
ii  postgresql-contrib-9.4            9.4.9-1.pgdg80+1
amd64        additional facilities for PostgreSQL
ii  postgresql-contrib-9.5            9.5.4-1.pgdg80+1
amd64        additional facilities for PostgreSQL
-------------------------------------------------------------------

attached files:

systemctl cat postgresql.service
systemctl cat postgresql@9.4-at_run.service
/etc/postgresql/9.4/at_run/postgresql.conf
/etc/postgresql/9.4/at_run/start.conf
/usr/bin/pg_ctlcluster

Best regards
Andreas

On 09/13/2016 05:52 PM, Peter Eisentraut wrote:
> On 9/9/16 6:50 AM, andreas.papst@univie.ac.at wrote:
>> when starting a hot standby database insstance with
>> `systemctl start postgresql',
>> anything works perfect: WAL files are beeing applied, r/o connections are
>> able to query the database, but after 90 seconds (systemd
>> DefaultTimeoutStartSec) postgresql is beeing shut down:
>
> This is all quite plausible, but it depends on how your systemd service
> for postgresql is configured.  So please post that if you want us to
> analyze it.
>

--
________________________________________________________________________
Andreas Papst                      |
Vienna University Computer Center  |  E-Mail: andreas.papst@univie.ac.at
Universitaetsstrasse 7             |  Phone: +43 1 4277 / 140 36
A-1010 Vienna, Austria, Europe     |  Fax.: +43 1 4277 / 8 140 36

Attachment
Something unusual is going on.  Try running the commands in the unit
file by hand and see whether they succeed or print additional
diagnostics.  Check the systemd logs, if any.  The reason the process
ends up getting killed is that systemd thinks it has not started
successfully.

--
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Hello,

On 09/15/2016 02:19 AM, Peter Eisentraut wrote:
> Something unusual is going on.  Try running the commands in the unit
> file by hand and see whether they succeed or print additional
> diagnostics.  Check the systemd logs, if any.  The reason the process
> ends up getting killed is that systemd thinks it has not started
> successfully.
>
yeah, when systemd's startup process is running into it's timeout
it terminates postgres process. If I change the timeout threshold
to unlimited, postgres operates for ever.
And as I wrote, when I send Postgres a signal, i.e. `systemctl reload
postgresql´, postgres process detaches, the blocked startup script
is freed and returns success to systemd.

No more logs are available.

Thanks
Andreas
--
________________________________________________________________________
Andreas Papst                      |
Vienna University Computer Center  |  E-Mail: andreas.papst@univie.ac.at
Universitaetsstrasse 7             |  Phone: +43 1 4277 / 140 36
A-1010 Vienna, Austria, Europe     |  Fax.: +43 1 4277 / 8 140 36