[Dbix-class] ROLLBACK seems to be skipped on 0.08

Jesper Krogh jesper at krogh.cc
Fri Oct 19 09:28:38 GMT 2007


> On 10/18/07, Jesper Krogh <jesper at krogh.cc> wrote:
>> There is a change in the behaviour of
>> $schema->txn_rollback from 0.07* to 0.08*
>>
>>
>> $ DBIC_TRACE=1 perl -I/tmp/0.07003/lib/ ./test.pl
>> DBIx::Class version: 0.07003
>> SELECT "me"."id", "me"."name", "modules"."id", "modules"."name",
>> "modules"."family_id" FROM "family" "me" LEFT JOIN "module" "modules" ON
>>  ( "modules"."family_id" = "me"."id" ) ORDER BY "modules"."family_id":
>> ROLLBACK
>>
>>
>> The "rollback" gets into the database.
>>
>>
>> $ DBIC_TRACE=! perl ./test.pl
>> DBIx::Class version: 0.08007
>> SELECT "me"."id", "me"."name", "modules"."id", "modules"."name",
>> "modules"."family_id" FROM "family" "me" LEFT JOIN "module" "modules" ON
>>  ( "modules"."family_id" = "me"."id" ) ORDER BY "modules"."family_id":
>> Issuing rollback() for database handle being DESTROY'd without explicit
>> disconnect().
>>
>> There we get a warning, probably because the $schema->txn_rollback in
>> the script doesn't get to the database.
>>
>> The script looks like this.
>>
>>
>> $ cat test.pl
>> #!/usr/bin/perl
>> #
>> use strict; use warnings; use lib "lib/"; use Testdb; print "DBIx::Class
>> version: " . $DBIx::Class::VERSION . "\n";
>> my $schema =
>> Testdb->connect("dbi:Pg:dbname=testdb2","super","super",{AutoCommit =>
>> 0});
>> $schema->txn_begin;
>> my @all = $schema->resultset("Family")->search({},{prefetch =>
>> "modules"});
>> $schema->txn_rollback;
>>
>>
>> 1;
>>
>>
>>
>
> The warning message you're seeing doesn't necessarily relate to the
> txn_rollback not making it to the database.  It's a general warning that
> would happen anytime you don't disconnect immediately before undefining a
> $dbh with AutoCommit=>0.  Can you double check your
> AutoCommit setting, and can you verify with a few more warning
> statements inserted near the bottom around the rollback call, and/or a
> final $schema->storage->dbh->disconnect()?

AutoCommit is 0 .. you can see it above, thats by intention.

As an answer to your question about the database. This is against
"postgresql 8.1"

I'm not sure if this is what you ask for but setting
$dbh->trace(1,"/tmp/trace" . $DBIx::Class::VERSION); gives

$ cat /tmp/trace0.07003
    DBI::db=HASH(0xf86690) trace level set to 0x0/1 (DBI @
0x0/47197395615744) in DBI 1.53-ithread (pid 4296)
    <- FETCH('Active')= 1 at DBI.pm line 529
    <- ping= 1 at DBI.pm line 529
    <- FETCH('AutoCommit')= '' at DBI.pm line 680
    <- FETCH('Active')= 1 at DBI.pm line 529
    <- ping= 1 at DBI.pm line 529
    <- prepare_cached('SELECT "me"."id", "me"."name", "modules"."id",
"modules"."name", "modules"."family_id" FROM "family" "me" LEFT JOIN
"module" "modules" ON ( "modules"."family_id" = "me"."id" ) ORDER BY
"modules"."family_id"' HASH(0xfa6ed0) ...)= DBI::st=HASH(0xf86880) at
DBI.pm line 881
    <- execute= 3 at DBI.pm line 773
    <- fetchrow_array= ( '1' 'Fam1' '1' 'Mod1' '1' ) [5 items] row1 at
Cursor.pm line 86
    <- FETCH('Active')= 1 at DBI.pm line 529
    <- ping= 3 at DBI.pm line 529
    <- rollback= 1 at DBI.pm line 737
    <- DESTROY(DBI::st=HASH(fa6fd0))= undef
    <- DESTROY(DBI::db=HASH(f86690))= undef

3 lines up.. I get the "rollback".

$ cat /tmp/trace0.08007
    DBI::db=HASH(0x1081f50) trace level set to 0x0/1 (DBI @
0x0/47540992999424) in DBI 1.53-ithread (pid 4301)
    <- FETCH('Active')= 1 at DBI.pm line 698
    <- ping= 1 at DBI.pm line 698
    <- prepare_cached('SELECT "me"."id", "me"."name", "modules"."id",
"modules"."name", "modules"."family_id" FROM "family" "me" LEFT JOIN
"module" "modules" ON ( "modules"."family_id" = "me"."id" ) ORDER BY
"modules"."family_id"' HASH(0x10b04d0) ...)= DBI::st=HASH(0x1082140)
at DBI.pm line 1168
    <- execute= 3 at DBI.pm line 990
    <- fetchrow_array= ( '1' 'Fam1' '1' 'Mod1' '1' ) [5 items] row1 at
Cursor.pm line 85
    <- DESTROY(DBI::st=HASH(10b0520))= undef
    <- DESTROY(DBI::db=HASH(1081f50))= undef
jk at plasmid:/tmp/testdb2$

No rollback present for 0.08


Jesper
-- 
Jesper Krogh





More information about the DBIx-Class mailing list