pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Could someone please help us share the procedure to troubleshoot the locks on proc issues.
3+ messages / 2 participants
[nested] [flat]

* Could someone please help us share the procedure to troubleshoot the locks on proc issues.
@ 2020-04-02 19:37 postgann2020 s <postgann2020@gmail.com>
  2020-04-02 23:00 ` Re: Could someone please help us share the procedure to troubleshoot the locks on proc issues. Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 3+ messages in thread

From: postgann2020 s @ 2020-04-02 19:37 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-performance@postgresql.org; pgsql-admin

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

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.

Attachments:

  Blocking_PROCS_With_PIDS.csv (application/vnd.ms-excel, 669B) download

  pg_stat_activity_output_for_clarification.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, 25.9K) download

  Lock_Reference_For_PROC.xlsx (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, 63.0K) download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Could someone please help us share the procedure to troubleshoot the locks on proc issues.
  2020-04-02 19:37 Could someone please help us share the procedure to troubleshoot the locks on proc issues. postgann2020 s <postgann2020@gmail.com>
@ 2020-04-02 23:00 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2020-04-03 05:11   ` Re: Could someone please help us share the procedure to troubleshoot the locks on proc issues. postgann2020 s <postgann2020@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Adrian Klaver @ 2020-04-02 23:00 UTC (permalink / raw)
  To: postgann2020 s <postgann2020@gmail.com>; pgsql-general@postgresql.org; pgsql-performance@postgresql.org; pgsql-admin

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Could someone please help us share the procedure to troubleshoot the locks on proc issues.
  2020-04-02 19:37 Could someone please help us share the procedure to troubleshoot the locks on proc issues. postgann2020 s <postgann2020@gmail.com>
  2020-04-02 23:00 ` Re: Could someone please help us share the procedure to troubleshoot the locks on proc issues. Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-04-03 05:11   ` postgann2020 s <postgann2020@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: postgann2020 s @ 2020-04-03 05:11 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general@postgresql.org; pgsql-performance@postgresql.org; pgsql-admin

Thanks Adrian, will share the details.

On Fri, Apr 3, 2020 at 4:30 AM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> 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
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2020-04-03 05:11 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 19:37 Could someone please help us share the procedure to troubleshoot the locks on proc issues. postgann2020 s <postgann2020@gmail.com>
2020-04-02 23:00 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-03 05:11   ` postgann2020 s <postgann2020@gmail.com>

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