Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGlZJ-0002kU-Me for pgsql-general@arkaria.postgresql.org; Wed, 17 Apr 2019 14:29:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hGlZI-00089X-Hl for pgsql-general@arkaria.postgresql.org; Wed, 17 Apr 2019 14:29:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGlZI-00089Q-8R for pgsql-general@lists.postgresql.org; Wed, 17 Apr 2019 14:29:44 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGlZG-0006gw-3j for pgsql-general@postgresql.org; Wed, 17 Apr 2019 14:29:43 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B451621C0F; Wed, 17 Apr 2019 10:29:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 17 Apr 2019 10:29:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=1 XThonLV2honP/ycUeRAwCmlUOny5gemznvYbrsabmI=; b=xy4UEukYBfDLUyVm8 PnB/U9rXiSx7RLMjAdpfXn20/HsErub95q4hFlCJ9jQmBGRZiqtmulRBT1yEGNUf w2AoXjyCumMTNaGjoR8S50oVDdNVI8oZViWosMrL4L1fiBWOe3qktw6Uv1TAM6uk Pm3TeWr6fLy50dC+moHaoB1tb+7r5IAXoTwwGOBCBlu6fXY+/5krlljW2oq+W+x+ tTXPzRnZpoJKq4AQZFUWEn+YfuHKTCCiuFd6uIj3n+Jg04hI5RcnzSQtgVj0VEGW hR4w/Z7cDAOGIl+WW2CdXcgQwpomzUAetnIDT5RzQom8Gu1PI6Rk3bIf8Mz2AK57 4iCdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=1XThonLV2honP/ycUeRAwCmlUOny5gemznvYbrsab mI=; b=whllavliEJjsSw3YIDeLzVzWsCKTIX43pWGVkIAZKWD68SsEfqG+PTptX z72J3wNJWTGacRcXDAxfz2+/nyQUDclP6Cg7YsUQbDQI1SNTqUeBSVTmN4w2TDVU 4YFb53N7XiXSZThJ0+YKM3oyJQxCPQZ4yjT1YE3vazobyKq9K/j/oBvOkfaF/z7n UDhnFDJHcKGPHCuebvpvhoG3JA2VQrRDd5DW0HE3mVrLqB6lxpwolwecOdUEa22r mzXobLP1nRbFiHNIa/pB2KhHzLlJ0IYNUtQ5koMmwnjCluYkhA1Run+7vgtQ3kR2 P7pqsq+eUAzUAQKvgyR+0jR+G25Pg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrfeefgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuffhomhgrihhnpehsthgrrhhtihhnghdrshgvlhgvtghtnecukfhppeejuddrvddu vddrudehtddrvddtvdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklh grvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 6AFEA103CF; Wed, 17 Apr 2019 10:29:39 -0400 (EDT) Subject: Re: PostgreSQL ping/pong to client To: Ajay Pratap , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: <70c44319-1ff8-8d26-ceba-db2b20d8496d@aklaver.com> Date: Wed, 17 Apr 2019 07:29:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/17/19 5:39 AM, Ajay Pratap wrote: > Hello there, > 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. If the server is exiting uncleanly I am not sure how it will gracefully close connections. > 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. > One of the methods is to configure TCP timeout but since this is very > impactful and hence unrealistic. > I was wounding how can out of the box PostgreSQL help me solve this. > May be like a ping pong service to check if client is still alive. > > Thanks and regards, > Ajay Pratap, > Software Engineer, > Drishti-Soft > > -- Adrian Klaver adrian.klaver@aklaver.com