[MTOS-dev] Making MT Transaction Safe

Alvar Freude alvar at a-blast.org
Tue Mar 11 06:02:23 PDT 2008


Hi,

-- Hirotaka Ogawa <hirotaka.ogawa at gmail.com> wrote:

> Yep.  I've not tested, but we can do as like:
>
>     unless ($options->{nocommit}) {
> 	eval {
> 	    $sth->execute;
> 	};
> 	if ($@) {
> 	    $driver->rollback;
> 	    Carp::croak("INSERT error $driver: $@");
> 	}
> 	$driver->commit;
>     } else {
> 	$sth->execute;
>     }
>     $sth->finish;

hmmm, usual the eval is around the whole transaction, all reading queries 
and other code included. The commit also must be inside the transaction. 
And when something fails, PostgreSQL needs an explizit rollback to 
enforce data integrity.

<http://search.cpan.org/~timb/DBI/DBI.pm#Transactions>


> Which is better?
>
> I think the former is better, because we can easily and explicitly see
> how transactions handle in MT Core.  The latter is surely easy to
> code, but too implicit, I guess.

Yes, I agree, the first one seems to be better (but more work).


But what about putting the whole HTTP request into one transaction, 
perhaps with an extra transaction for the session?


Ciao
  Alvar



-- 
** Alvar C.H. Freude, http://alvar.a-blast.org/
** http://www.assoziations-blaster.de/
** http://www.wen-waehlen.de/
** http://odem.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
Url : http://www.sixapart.com/pipermail/mtos-dev/attachments/20080311/abc8353c/attachment.bin 


More information about the MTOS-dev mailing list