[CDBI] dbi_commit not adding everything under mod_perl

Steve Sims steve at karmamusicgroup.com
Wed Apr 19 14:50:42 BST 2006

Hi Perrin,

Thanks for the reply,

On 18 Apr 2006, at 18:36, Perrin Harkins wrote:
> On Tue, 2006-04-18 at 18:06 +0100, Steve Sims wrote:
>> One major problem I'm facing though is that records added to the
>> database from scripts run under mod_perl seem to vanish.
> Check that you are calling dbi_commit (or have explicitly turned on
> AutoCommit) and that your isolation level is set to something like  

Yeah - I'm making calls to dbi_commit - and have AutoCommit turned  
off.  I don't know how to check the isolation level.

> Also, how do you know the objects which should be there are not there?
> Are you looking through the terminal, or is there some code that  
> should
> find them but isn't?  Can you show it?

I'm checking the database with PgAdmin.  I see the records I updated,  
and sequence numbers for the tables where I tried to add records, but  
I do not see the new records I tried to add.

Having thought some more about this problem I suspect that the way  
that records get created in my web site scripts could be the  
problem.  The calls that make the new records occur in subroutines  
and do not keep the returned record; they are just in the form  
"MyCDBI::Obj->create(%stuff);".  I'm guessing that once that  
subroutine exits mod_perl garbage collects the orphaned new records,  
calling their destructor and thus effectively deleting them before  
they are committed.

The scripts on my site running under mod_perl that *do* manage to add  
records to the database keep references to the records that get added  
until dbi_commit has been called.

I suspect that the regular command line Perl interpreter doesn't  
garbage collect quite as aggressively as mod_perl, so when these  
scripts are run outside of mod_perl they execute just fine.

The implication of this if I'm right is that my scripts are doing  
things wrong and should be keeping references to all newly created  
Class::DBI record objects until such time as they have been committed  
to the database.

If I'm right about this, then I guess I'm just lucky that my scripts  
work with the regular command line Perl interpreter.


More information about the ClassDBI mailing list