Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jK8ow-00040q-6X for pgsql-admin@arkaria.postgresql.org; Thu, 02 Apr 2020 23:00:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jK8ou-0008Fa-8q for pgsql-admin@arkaria.postgresql.org; Thu, 02 Apr 2020 23:00:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jK8ot-0008FO-DA; Thu, 02 Apr 2020 23:00:20 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jK8op-0007ix-WA; Thu, 02 Apr 2020 23:00:19 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6A4F55C02B2; Thu, 2 Apr 2020 19:00:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 02 Apr 2020 19:00:14 -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=x MrvsvkryuXgMfSOewM3lQ3rS78KBE9ErBErxN34J7Y=; b=C0iH2rFUbzWBXAa9l N7IUg2yKxDWaYrXtx1YKVBK/VknKPl0EtBsZ9U0bvO4rO7hSgf8fRJHADe3nLtEo XD7x6WthHPE2LVLp47CL+Cnv4of0jwSnG46xOQGgjkuV5gXA2qAj/wTpEwb/eWFl wYEFMOfi+XwGvXR3Lf81EvHGCck73j8uUPSv6c6Vdxa4uBUedhmltFa5guEmkxJT +Fk93aH9xLf8KqCPxQuwScBV2MMcqPUIl2K/lfc6Ka+1bb2BtdJEiIRrg3wYUUvO S7yDtd6RNOfjseF2vBTjXhrRQfE2FG5WX18EQVR9rPM46fAo+LUkLxbhp/NzXQMW XL4IQ== 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=xMrvsvkryuXgMfSOewM3lQ3rS78KBE9ErBErxN34J 7Y=; b=vOsxE9/aOM9LETAP5yQAT07CGb2fQP8rOilLOf8GM5newgqOoT8Yc09iZ QmSPDxfSNz/i5SiMTImLSkrzUpG6CcRxc8FTm1vmfGvgJri8RgS8jcXsnPsToHZj MiVdvlSyzztoJe291+zae6yuinyTGewTkhe6wcqW8OlECH+IyEP9ceum+3sXK9gr pHGXqaJBj3lcv8UXFJJk3gXJ714Ix55I7h+m4u6CTXOXatzYsPpN6kfQc1vVvN2b OdiIiSABJMdX9uR+8TNwqiF08OUQACVAEHHOlGV/UaQl9seC9YhtGR9PI36irFx7 Alh78UkyB5yne7R8GG4fmUViyPX2g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrtdehgdduiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecukfhppeejhedrudejvddrledtrdelvdenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvg hrrdgtohhm X-ME-Proxy: Received: from [192.168.1.10] (75-172-90-92.tukw.qwest.net [75.172.90.92]) by mail.messagingengine.com (Postfix) with ESMTPA id 7100C306CE90; Thu, 2 Apr 2020 19:00:13 -0400 (EDT) Subject: Re: Could someone please help us share the procedure to troubleshoot the locks on proc issues. To: postgann2020 s , pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-admin@postgresql.org References: From: Adrian Klaver Message-ID: Date: Thu, 2 Apr 2020 16:00:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/2/20 12:37 PM, postgann2020 s wrote: > Hi Team, > > Good Evening, > > Could someone please help us share the procedure to troubleshoot the > locks on proc issues. > > Environment: > ============ >  1 pgpool server (Master Pool Node) using Straming replication with > load balancing >  4 DB nodes (1Master and 3 Slaves). > >  Versions: >  1. postgres: 9.5.15 >  2. pgpool   : 3.9 >  3. repmgr:  4.1 > > We are continuously facing locking issues for below procedures , due to > this the  rest of the call for these procs going into waiting > state.Which cause the DB got hung. Below are the procs  running with > DB_User2 from the application. > > 1. select * from Schema1.duct_remove_validation($1,$2,$3,$4)  ==> This > proc it self calling Schema1.cable_remove_validation($1,$2). > 2. select * from Schema1.cable_remove_validation($1,$2)  ==> This is > also calling from the applications To figure out below we need to see what is happening in above. > > if we ran explain analyze, its taking msec only, but if we run > simultaneouly from application getting locked and waiting state. > > We have ran below query for showing blocking queries and attached output > in Blocking_Queries_with_PID.csv file: > > SELECT > pl.pid as blocked_pid > ,psa.usename as blocked_user > ,pl2.pid as blocking_pid > ,psa2.usename as blocking_user > ,psa.query as blocked_statement > FROM pg_catalog.pg_locks pl > JOIN pg_catalog.pg_stat_activity psa > ON pl.pid = psa.pid > JOIN pg_catalog.pg_locks pl2 > JOIN pg_catalog.pg_stat_activity psa2 > ON pl2.pid = psa2.pid > ON pl.transactionid = pl2.transactionid > AND pl.pid != pl2.pid > WHERE NOT pl.granted; > > Output: attached output in Blocking_Queries_with_PID.csv file > > > The waiting connections are keep on accumulating and cause DB hung. > I have attached pg_stat_activity excel file with the user along with the > proc queries which cause waiting state. > > Finds: > > There are total 18 connections for DB_User2 which are running only above > 2 procs, Out of that only one connection with 18732 is running proc > (select * from Schema1.duct_remove_validation($1,$2,$3,$4))from long > time  and reset of all 17 connections are in waiting state from the long > time. > > There are many exclusive locks on table for 18732 and other process as > well. I have attached pg_locks reference excel(Lock_Reference_For_PROC) > with highlighted pid 18732. > > Could someone please suggest the procedure to troubleshoot this issue. > Please find the attachment for reference. > > Thanks, > Postgann. -- Adrian Klaver adrian.klaver@aklaver.com