Re: PostgreSQL ping/pong to client

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Ajay Pratap <ajaypratap(at)drishti-soft(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL ping/pong to client
Date: 2019-04-17 14:48:19
Message-ID: 30388.1555512499@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
> On 4/17/19 5:39 AM, Ajay Pratap wrote:
>> I am using PostgreSQL 10.7 as the database, and have Java web app. My
>> app takes a lock on the database using the following command whenever my
>> server is starting.
>> /select /pg_try_advisory_lock/(100)/
>> To make sure only one instance of the App is using the database at a time.
>> There have been several instances when my server crashes(or stops/ or
>> kill), but this lock still remained on the PostgreSQL. Ideally, this
>> should not happen because TCP connection breaks if one of the peers
>> dies, but it happens otherwise.
>> To solve this problem PostgreSQL needs to break the connection if the
>> client dies.

> But the problem as you describe it is that the server dies not the client.

An advisory lock wouldn't survive a server reboot, so there's something
not very accurate about this description.

I suspect what the OP wants is quicker detection of client connection
loss, and yes, messing with TCP timeouts and/or keepalive is the only way.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Kane 2019-04-17 15:34:02 Re: Alter domain type / avoiding table rewrite
Previous Message Ajay Pratap 2019-04-17 14:39:30 Re: PostgreSQL ping/pong to client