pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Too many Row Exclusive Locks held for a long time
2+ messages / 2 participants
[nested] [flat]

* Re: Too many Row Exclusive Locks held for a long time
@ 2019-03-07 14:37  pavan95 <pavan.postgresdba@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: pavan95 @ 2019-03-07 14:37 UTC (permalink / raw)
  To: pgsql-admin

Hi Community,

Hope my mail finds you in fine time.   

I am facing an issue in one of the production servers.

I have been observing there are many "Row Exclusive" locks occurring on a
set of similar tables around 2000 locks at any given point of time.  And
then the application(Odoo) is being struck for a very long time.

After we kill those Row Exclusive locks all the locks were released.

Typically the below is the sample statement being run on database by the
application users:

SELECT id FROM abc WHERE id=5075 FOR UPDATE NOWAIT;

So every time this issue occurs we need to go into server identify the "Row
Exclusive Locks" process id's and kill them after which it works fine.

So is there any permanent fix for this that we need to look upon?

Kindly shed some light on this area.  

Thanks in Advance. Looking forward to hear from you.

Regards,
Pavan Teja,
9841380956



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-admin-f2076596.html




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

* Re: Too many Row Exclusive Locks held for a long time
@ 2019-03-07 19:30  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: pavan95 <pavan.postgresdba@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Laurenz Albe @ 2019-03-07 19:30 UTC (permalink / raw)
  To: pavan95 <pavan.postgresdba@gmail.com>; pgsql-admin

pavan95 wrote:
> I am facing an issue in one of the production servers.
> 
> I have been observing there are many "Row Exclusive" locks occurring on a
> set of similar tables around 2000 locks at any given point of time.  And
> then the application(Odoo) is being struck for a very long time.
> 
> After we kill those Row Exclusive locks all the locks were released.
> 
> Typically the below is the sample statement being run on database by the
> application users:
> 
> SELECT id FROM abc WHERE id=5075 FOR UPDATE NOWAIT;
> 
> So every time this issue occurs we need to go into server identify the "Row
> Exclusive Locks" process id's and kill them after which it works fine.
> 
> So is there any permanent fix for this that we need to look upon?

ROW EXCLUSIVE is the lock taken on a table if a transaction wants to perform
INSERT, UPDATE or DELETE.  It is a harmless lock.

If your application is getting stuck where such a lock is involved, that means:

1. A lock is held for a long time.

2. Something requests a conflicting lock, i.e. SHARE or higher.

Long transactions are evil not only because they hold locks,
but also because they prevent VACUUM from doing its job.

Taking high table locks (probably with an explicit LOCK statement) is something
hat should not be done regularly.  For one, it makes autovacuum give up, which
can lead to table bloat.

Try to figure out what causes the high table lock (you should see it stuck
behind a ROW EXCLUSIVE lock or vice versa).

Try to fix the application so that it uses short transactions.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





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


end of thread, other threads:[~2019-03-07 19:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 14:37 Re: Too many Row Exclusive Locks held for a long time pavan95 <pavan.postgresdba@gmail.com>
2019-03-07 19:30 ` Laurenz Albe <laurenz.albe@cybertec.at>

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