pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Ajay Pratap <ajaypratap@drishti-soft.com>
Cc: pgsql-general@postgresql.org
Subject: Re: PostgreSQL ping/pong to client
Date: Wed, 17 Apr 2019 10:48:19 -0400
Message-ID: <30388.1555512499@sss.pgh.pa.us> (raw)
In-Reply-To: <70c44319-1ff8-8d26-ceba-db2b20d8496d@aklaver.com>
References: <CABi=8qzPO-TOMsfRoWKVUtaAa=HzkPSCzYxo61CRsVfgT0hX4g@mail.gmail.com>
	<70c44319-1ff8-8d26-ceba-db2b20d8496d@aklaver.com>

Adrian Klaver <adrian.klaver@aklaver.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





view thread (9+ messages)  latest in thread

Message-ID: <30388.1555512499@sss.pgh.pa.us>
Permalink:  ../30388.1555512499@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/30388.1555512499@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, ajaypratap@drishti-soft.com
  Subject: Re: PostgreSQL ping/pong to client
  In-Reply-To: <30388.1555512499@sss.pgh.pa.us>
  References: <CABi=8qzPO-TOMsfRoWKVUtaAa=HzkPSCzYxo61CRsVfgT0hX4g@mail.gmail.com> <70c44319-1ff8-8d26-ceba-db2b20d8496d@aklaver.com> <30388.1555512499@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox