|Syntactic Confectionery Delight
Re: Implementing rowlockingby ikegami (Patriarch)
|on Jan 09, 2007 at 16:08 UTC
[ I see solutions. Hopefully, I can shed some light on the problem. ]
First, it's important to realize that you want to lock a record for an extended period of time, one that can span longer than a connection. (arkturuz, herveus and myself in the chat last night didn't realize this.)
There are two major problems with doing your own locking. The length of time for which you want to lock a record exacerbates both.
First, the situation where you're trying to lock something that's already locked is hard to handle. If you were to use LOCK TABLE, it would block until the lock is obtained. If you were to use your own locking mechanism, then you'd have to keep trying to lock the data. That could put a heavy load on the DB if multiple clients are trying to lock locked records.
Second, a crashed client can hold a record locked indefinitely. You could timeout locks, but that's dangerous.