[CDBI] Is standard idiom for transactions really safe?
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
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ClassDBI