On Wed, 18 Oct 2006 00:39:20 +0900, M. Edward (Ed) Borasky wrote:

> Ken Bloom wrote:
>> On Tue, 17 Oct 2006 08:46:42 -0400, Paul wrote:
>> 
>>> I'm exploring learning RoR, then using it for a new start project.  Been 
>>> reading allot of RoR comparisons to Java.... I'm not formally educated in 
>>> enterprise client/server and have some Q's regarding some of what I've read.
>>>
>>> 1.   Two-phase commit:  The general tone I read was "if you need a two-phase 
>>> commit, use Java." What is a two-phase commit?  When/Why/Where would I want 
>>> it?  Since I lived without it so far, I think I'm OK now, but I like to plan 
>>> projects with potential for future growth.  If someday I did have a business 
>>> case for 2-phase commit, could I do something in RoR to meet that need?
>> 
>> Two phase commit is a protocol for commiting a single transaction that
>> spans multiple databases. It's supposedly difficult to do in Java too, but
>> if you need it you can look into database middleware that can coordinate
>> distributed transactions so that it appears to your rails app as
>> though you're only working with one database.
>> 
>> --Ken Bloom
>> 
> 
> Two-phase commit is what makes transactions have the ACID properties!
> Lack of two-phase commit is a show-stopper for many database-backed
> applications, and if Rails doesn't support it somehow, I'd be extremely
> surprised.

You're thinking of two phase locking. Two phase locking ensures ACI in a
database (whether distributed or not), by acquiring all locks in a
transaction as you query/update the objects needed (the first phase), and
by releasing them all at the same time[*] when you commit (the second phase).

In two phase commit, the coordinator of a distributed transaction queries
all of the distributed sites and asks them whether it's safe to commit. If
any veto the commit (or miss the timeout indicating that they have
crashed), the coordinator tells all sites to roll back. Otherwise, the
coordinator tells all sites to go ahead and commit.

--Ken
[*] the "same time" requirement technically makes this "strict two phase
locking".
-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/
I've added a signing subkey to my GPG key. Please update your keyring.