Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-20 Thread Enrico Thierbach
-- me at github: https://github.com/radiospiel me at linked.in: https://www.linkedin.com/in/radiospiel ​You probably considered this but the queuing mechanism I use doesn't hold locks on records during processing. Workers claim tasks by locking them, setting a claimed flag of some sort, th

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-16 Thread David G. Johnston
On Fri, Mar 16, 2018 at 8:00 AM, Enrico Thierbach wrote: > Hi Melvin, Stephen, hi list, > > *FWIW, I really don't understand your need to identify the actual rows that > are locked. Once you have identified the query that is causing a block > (which is usually due to "Idle in Transaction"), AFAIK

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-16 Thread Enrico Thierbach
Thanks Steven, Evidently my second email got lost somewhere along the way- what you're looking for is an extension called 'pgrowlocks': https://www.postgresql.org/docs/10/static/pgrowlocks.html My prior email on that subject is here: https://www.postgresql.org/message-id/20180315220512.GV241

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-16 Thread Stephen Frost
Enrico, * Enrico Thierbach (e...@open-lab.org) wrote: > >*FWIW, I really don't understand your need to identify the actual rows > >that > >are locked. Once you have identified the query that is causing a block > >(which is usually due to "Idle in Transaction"), AFAIK the only way to > >remedy the

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-16 Thread Enrico Thierbach
Hi Melvin, Stephen, hi list, *FWIW, I really don't understand your need to identify the actual rows that are locked. Once you have identified the query that is causing a block (which is usually due to "Idle in Transaction"), AFAIK the only way to remedy the problem is to kill the offending quer

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-16 Thread Stephen Frost
Greetings, Please don't top-post. * Melvin Davidson (melvin6...@gmail.com) wrote: > this whole discussion started because Enrico did not originally specify the > PostgreSQL version he was working with. So after he did advise it was for > 9.6, I felt it necessary to explain to him why a certain se

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-16 Thread Melvin Davidson
Tom, this whole discussion started because Enrico did not originally specify the PostgreSQL version he was working with. So after he did advise it was for 9.6, I felt it necessary to explain to him why a certain section of my query was commented out and that it would also work for 10. I have previo

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Tom Lane
Melvin Davidson writes: > Yes, Stephen, I certainly understand making changes to system catalogs > _when necessary_. That being said, the first change was the renaming of > pid to procpid in pg_stat_activity. However, I contend that was more > because someone felt that it was more to make the co

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Stephen Frost
Greetings Melvin, * Melvin Davidson (melvin6...@gmail.com) wrote: > On Thu, Mar 15, 2018 at 10:14 PM, Stephen Frost wrote: > > Changes will continue to be made between major versions of PostgreSQL > > when they're deemed necessary; I'd suggest those applications be > > prepared to adjust on a per

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Melvin Davidson
On Thu, Mar 15, 2018 at 10:14 PM, Stephen Frost wrote: > Greetings Melvin, > > * Melvin Davidson (melvin6...@gmail.com) wrote: > > >I guess with your query I can figure out which connection holds a lock, > > but it seems I cannot correlate those locks to the rows which actually > are > > locked,

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Stephen Frost
Greetings Melvin, * Melvin Davidson (melvin6...@gmail.com) wrote: > >I guess with your query I can figure out which connection holds a lock, > but it seems I cannot correlate those locks to the rows which actually are > locked, since pg_locks seems not to reference this in any way. > > *FWIW, I r

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Melvin Davidson
>I guess with your query I can figure out which connection holds a lock, but it seems I cannot correlate those locks to the rows which actually are locked, since pg_locks seems not to reference this in any way. *Enrico,* *FWIW, I really don't understand your need to identify the actual rows t

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Stephen Frost
Greetnigs, * Enrico Thierbach (e...@open-lab.org) wrote: > I guess with your query I can figure out which connection holds a lock, but > it seems I cannot correlate those locks to the rows which actually are > locked, since `pg_locks` seems not to reference this in any way. What I gave you would

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Enrico Thierbach
Hi Melvin, hi everyone else, thank you for your support, and for your query example. And oh yes, I forgot to mention the postgres version, which is 9.6; but if I find a solution which works in Version 10 then I could probably update. I guess with your query I can figure out which connection h

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Melvin Davidson
On Thu, Mar 15, 2018 at 4:48 PM, Stephen Frost wrote: > Greetings, > > * Enrico Thierbach (e...@open-lab.org) wrote: > > I am using `SELECT * FROM queue ... FOR UPDATE SKIP LOCKED` to implement > a > > queueing system. > > > > Now I wonder if it is possible, given the id of one of the locked rows

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Stephen Frost
Greetings, * Enrico Thierbach (e...@open-lab.org) wrote: > I am using `SELECT * FROM queue ... FOR UPDATE SKIP LOCKED` to implement a > queueing system. > > Now I wonder if it is possible, given the id of one of the locked rows in > the queue table, to find out which connection/which transaction

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread David G. Johnston
On Thu, Mar 15, 2018 at 1:30 PM, Enrico Thierbach wrote: > Now I wonder if it is possible, given the id of one of the locked rows in > the queue table, to find out which connection/which transaction owns the > lock > ​I'd start here:​ https://www.postgresql.org/docs/10/static/view-pg-locks.html

Re: SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread pinker
Check out here: https://wiki.postgresql.org/wiki/Lock_Monitoring -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

SELECT .. FOR UPDATE: find out who locked a row

2018-03-15 Thread Enrico Thierbach
Hello, I am using `SELECT * FROM queue ... FOR UPDATE SKIP LOCKED` to implement a queueing system. Now I wonder if it is possible, given the id of one of the locked rows in the queue table, to find out which connection/which transaction owns the lock. Any help is greatly appreciated. Than