[Rails] Concurrecy question with ActiveRecord
Rick Bradley
rick at rickbradley.com
Thu Dec 9 22:00:44 GMT 2004
* ChongQing Xiao (CqXiao at epicsystems.com) [041209 16:33]:
> For web application, I think there are two ways to address the problem
>
> 1. Implement some application level lock so once a patient is marked as
> locked, another user can only read the data from the web server so no
> conflict will happen.
>
> 2. Allow two users to change the data at the same time but roll back the
> last change if the change conflicts according the time stamp as I have
> mentioned in my previous email
This topic is well-studied and often comes down to a choice between
optimistic and pessimistic locking, but there are a lot of complicating
factors (request length, ability to resolve conflicts automatically in
the problem domain, the cost of a collision, etc.). Martin Fowler
covers this general concurrency problem as it relates to enterprise web
applications in his _Patterns of Enterprise Application Architecture_. [0]
Clearly, the more you know about your particular application, its
business logic, and the nature of your session transactions the more
readily you can answer your own question and choose a suitable
implementation. It's very difficult for a framework to solve this type
of concurrency problem generally and flexibly. I haven't seen anything
in the Rails technologies that gets in the way of handling long
transaction concurrency, but you're not going to find a quick solution
either.
[0] http://www.martinfowler.com/books.html
Best,
Rick
--
http://www.rickbradley.com MUPRN: 879
| .sig? <p>-----Original
random email haiku | Message----- <p>David- <p>Check out
| www.distributed.net.
More information about the Rails
mailing list