Keep It Simple, Stupid | |
PerlMonks |
Re: Implementing rowlockingby oyse (Monk) |
on Jan 09, 2007 at 15:05 UTC ( [id://593737]=note: print w/replies, xml ) | Need Help?? |
Thanks for all the replies. I see that I was clearly to vague in my original post, so I shall try to give some more details. This is a web-application and I have not found any reliable way to unlock rows when a users leaves a page, closes the web-browser etc. So to prevent a user from holding a lock that is no longer used, I want the following behaviour: A lock is only valid for a short time (for instance 5 minutes). After that the lock is not counted as a lock anymore; it is invalid. If a user wants to keep the lock longer, she must ask for it explictly, in which case the lock is held for another 5 minutes (or some other time).
Regarding what herveus said:
Regarding what davidrw said:
Regarding what SheridanCat said: BTW I think I have a race condition free implementation in Perl now thanks to one of the people that helped my at the chatterbox. The person suggested letting the column that identifies a locked row have a UNIQUE constraint. When performing and insert the RDBMS will reject an insert that tries to lock a row (by inserting into the ROWLOCK table) that is already locked and DBI will cast an exception. By placing the DBI execute call in an eval{} it is easy to see if the user acquired the lock or not, and two users can not have the lock at the same time. I will now look more close at your suggestion and see if I should do something differently. Thanks again for all replies.
In Section
Seekers of Perl Wisdom
|
|