[Dbix-class] Options to avoid "Issuing rollback() for database..." (aka. AutoCommit and DBIx (again))

Matt S Trout dbix-class at trout.me.uk
Mon May 5 11:53:48 BST 2008


On Mon, May 05, 2008 at 10:02:59AM +0200, Erik Wasser wrote:
> The problem is (to get more specific) that I'm getting a "Issuing 
> rollback() for database handle being DESTROY'd without explicit 
> disconnect()" warning at the end of my code. That tells me that there 
> is one ongoing transaction at the end of the program.
> 
> So here's is some (pseudo)code:
> 
> ------------------------------------------------------------------------
> 
> # You can use any kind of schema (I'm not using any special methods
> # or overloading stuff). Neither the kind of database does matter.
> my $schema = TestDatabase->connect(
>    "dbi:SQLite:dbname=database.sqllite", "", "",
>    { PrintError => 1, RaiseError => 1, AutoCommit => 0 }
> );

Use AutoCommit => 1.

DBIC's reconnect logic pays attention to the transaction depth for whenever
it can retry, so you're going to get a lot more exceptions if you use 0.

Then if you make your legacy code use $storage->dbh_do you'll get the
same level of safety as DBIC internals do, pretty much.

Alternatively, do what thou wilt. But AutoCommit 0 just isn't supported;
if you don't know what you're doing well enough to work it out for yourself
you probably don't know what you're doing well enough to code safe DBIC
code using it. I certainly don't think -I- do (so if you think I'm calling
you an idiot, I'm calling -me- an idiot as well :).

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list