Re: [GENERAL] Need some help in postgres locking mechanism

2014-04-15 Thread santhosh kumar
Hi I am locking some rows using select for update(nowait=true) inside a transaction.If server in which code exists crashes,locks will be on rows.Those should be removed manually.I donot want that.I want to keep a timeout for that transaction.Could you please helpme out with a solution for this issu

Re: [GENERAL] Need some help in postgres locking mechanism

2014-04-08 Thread santhosh kumar
Thanks alot..i have implemented in same format.You people are awesome.Thank You once again On Tue, Apr 8, 2014 at 8:58 PM, Hannes Erven wrote: > Hi, > > > On 2014-04-08 15:27, Vick Khera wrote: > [...] > > Problem 2: you cannot have a second process skip over locked rows. >> > > > In fact, you

Re: [GENERAL] Need some help in postgres locking mechanism

2014-04-08 Thread Vick Khera
On Tue, Apr 8, 2014 at 11:28 AM, Hannes Erven wrote: > On 2014-04-08 15:27, Vick Khera wrote: > [...] >> >> Problem 2: you cannot have a second process skip over locked rows. > > > > In fact, you can: use "FOR UPDATE NOWAIT" and catch any errors. > > e.g. SELECT * FROM jobqueue WHERE id=? FOR UPDA

Re: [GENERAL] Need some help in postgres locking mechanism

2014-04-08 Thread Hannes Erven
Hi, On 2014-04-08 15:27, Vick Khera wrote: [...] Problem 2: you cannot have a second process skip over locked rows. In fact, you can: use "FOR UPDATE NOWAIT" and catch any errors. e.g. SELECT * FROM jobqueue WHERE id=? FOR UPDATE NOWAIT -hannes -- Sent via pgsql-general mailing list (p

Re: [GENERAL] Need some help in postgres locking mechanism

2014-04-08 Thread Vick Khera
Problem 1: how (and why) are you locking rows in table Y? Problem 2: you cannot have a second process skip over locked rows. It sounds to me like a job queue... what you want to do is make it work *really* fast to mark the job as taken and commit that work so the locks are released. Then go do the

[GENERAL] Need some help in postgres locking mechanism

2014-04-03 Thread santhosh kumar
Hi I have two problems to discuss.an you please guide me how to proceed on this. *problem 1:* I have table X('a' is prmiary key) and table Y('b' is primary key). Table Y has ''a''(X primary key) as foreign key.I have one job which runs once in one hour.I want to lock the rows in table Y.but this wi