Re: [CDBI] dbi_commit not adding everything under mod_perl

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
On Wed, 2006-04-19 at 14:50 +0100, Steve Sims wrote:
> Yeah - I'm making calls to dbi_commit - and have AutoCommit turned  
> off.  I don't know how to check the isolation level.

It must be in the Pg docs somewhere.  It's an important thing to
understand with any RDBMS in a multi-user environment, so well worth a
few minutes to read up on.

> 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.

It really sounds like no commit is happening to me.  Try using DBI_TRACE
to check if the commit goes through or not.

> 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.

Create does an immediate insert, but you still have to call commit
afterward.

> 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.

That shouldn't matter, as long as you call commit on the database
connection used to insert the records.

> I suspect that the regular command line Perl interpreter doesn't  
> garbage collect quite as aggressively as mod_perl

There's no difference: mod_perl is perl.

- Perrin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.