> Yes, you could use CFtransaction for this type of isolation, 
> but this can also cause problems that you wouldn't see with 
> cflock. Cftransaction isoloation='serializabile' for example 
> will give you an exclusive lock to all tables within the 
> transaction (most restrictive level of isloation). Depending 
> on what you're doing, this can be desirable or problematic as 
> this can easily cause database deadlocks which are almost 
> always highly frustrating to the end user, and are usually 
> equally frustrating to debug. Cflock will not (directly) 
> cause database deadlocks, but can be problematic if you have 
> a large number of requests that are going to be using the 
> cflock'ed code as a lock will wait (until timeout) for the 
> locked resource to be released. 
> 
> So potential database lock error vs potential cflock timeout 
> error - the choice is yours. :)

Databases provide concurrency control for exactly this purpose. If I want to
control concurrent access within the database, I want to use the
functionality that the database provides. It's there for a reason.
Recommending the synchronization of application code to solve database
concurrency problems goes against best practices for database applications
as well as common sense. If you can use a less restrictive isolation level,
of course, you should.

As for deadlocks, these don't just happen - they require a certain level of
complexity within your transactional logic. You need to have conflicting
transactions which access the same resources in different order. For
example, transaction 1 locks table A and needs to then lock table B, while
transaction 2 locks table B and needs to then lock table A. This isn't as
common as you imply. In any case, most DBMSs simply kill one of the two
transactions to resolve the deadlock, and I don't see how that's any worse
than a lock timeout from the end user's perspective - they both result in
"no workie".

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288241
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to