[CDBI] Is standard idiom for transactions really safe?

Ryan Tate lists at ryantate.com
Thu Mar 2 18:59:49 GMT 2006


On 3/2/06, Perrin Harkins <perrin at elem.com> wrote:

> That would be a very rare event.

This is true, but it is certainly worth thinking about on some level,
since the whole point of using transactions is protect against rare
edge cases that can wreak havok on data.

Like database servers randomly disconnecting in the middle of the
transaction. In this case under the existing idiom, the original
transaction would be aborted, but the remaining half of the
transaction would proceed, defeating the whole point of having a
transaction there and possibly corrupting the data model. Do I
misunderstand?

In a fantasy world, it would be possible to do something like

My::DBI->transaction_safe;
#AutoCommitt now ALWAYS on for any connects from this and all child
classes in this interpreter
$code->();
My::DBI->transaction_done;

This would essentially do the global TRANSACTION_ACTIVE flag you're
talking about but in a supported, slightly easier manner. But I
suspect this is an Ima::DBI issue more than a CDBI issue.

> and in way that mysql_auto_reconnect can't deal with.

A wise man once said, in response to a post about auto reconnect not
playing well with a mod_perled CDBI app, "auto-reconnect is (IMHO) a
bad idea for all but the most trivial of applications."




More information about the ClassDBI mailing list