[CDBI] Is standard idiom for transactions really safe?

Phil Mitchell phil at 2people.org
Thu Mar 2 18:32:07 GMT 2006


On 3/2/06, Perrin Harkins <perrin at elem.com> wrote:
>
> Phil Mitchell wrote:
> > connect_cached *tries* to return the same dbh, but
> > afaik can't guarantee it. And in the rare event that dbh changes in the
> > middle of a transaction, the new dbh will not have AutoCommit turned
> off.
>
> That would be a very rare event.  It is possible, but would involve
> either your code cutting the connection after changing AutoCommit, or
> the database server failing at just the right point for just the right
> amount of time, and in way that mysql_auto_reconnect can't deal with.
> If you're really worried about it, you could create a global
> "TRANSACTION_ACTIVE" flag, and modify Ima::DBI to throw an exception
> instead of reconnecting if it sees that.


Hmm, okay. I'm not trying to be super-paranoid, just wanted to see if I was
missing something -- I don't have a good feel for how rare these events
actually are. Btw, according to DBD::mysql docs, auto_reconnect is turned
off whenever AutoCommit is off. But anyway, I'm using SQLite right now, and
migration path is to postgresql.

Thanks, Perrin.

--
==========================
http://www.2people.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20060302/4beb895c/attachment.html


More information about the ClassDBI mailing list