Forum: Rails-core (closed, excessive spam) Move transaction counter from Thread.current to the connection object

Posted by Jonathan Viney (jviney)
on 2008-07-02 07:44
(Received via mailing list)
I've updated the patch for the ticket at
http://dev.rubyonrails.org/ticket/10212.

New ticket here:

http://rails.lighthouseapp.com/projects/8994/tickets/533-fix-nested-transactions-across-multiple-databases

It moves the counter for the number of open transactions from 
Thread.current
(which seems a very odd place to keep it), to the connection object. 
This
means that transactions across multiple database connections can be 
properly
supported.

Comments please.

Cheers,
-Jonathan.
Posted by Jonathan Viney (jviney)
on 2008-07-15 13:28
(Received via mailing list)
Anyone able to look at, comment on, or apply this ticket?

On Wed, Jul 2, 2008 at 5:43 PM, Jonathan Viney 
<jonathan.viney@gmail.com>
Posted by Michael Koziarski (Guest)
on 2008-07-15 13:36
(Received via mailing list)
On Tue, Jul 15, 2008 at 1:27 PM, Jonathan Viney
<jonathan.viney@gmail.com> wrote:
> Anyone able to look at, comment on, or apply this ticket?

Transactions across multiple database connections won't really 'work'
with this will they?  an error in one won't roll back the other and
you don't get transactional guarantees like you would with a full two
phase commit.  Are there any other functional benefits?

However, the connection handling code is pretty gross and Nick Sieger
from the jruby guys has been looking at refactoring it to use a
connection pool.  I'd try to touch base with him and get this merged
into his branch which will eventually make its way into the mainline.


--
Cheers

Koz
Posted by Jonathan Viney (jviney)
on 2008-07-15 14:58
(Received via mailing list)
Quite right, they won't be fully functional in that sense, but it is
certainly an improvement. An exception in the inner transaction will 
cause
the outer one to rollback as long as it isn't caught and discarded (as 
the
test shows).

This change at least makes multi-database transactions usable for those 
who
need it. Also, according to the original Trac ticket (
http://dev.rubyonrails.org/ticket/10212), this used to work before Rails
2.0.

-Jonathan.

On Tue, Jul 15, 2008 at 11:34 PM, Michael Koziarski 
<michael@koziarski.com>
This topic is locked and can not be replied to.