[CDBI] Use with mod_perl caching question

Michael G Schwern schwern at pobox.com
Sat Dec 15 09:39:17 GMT 2007

Rolf Schaufelberger wrote:
> Hi, 
> On Thursday 13 December 2007 18:20:01 Perrin Harkins wrote:
>> On Dec 13, 2007 11:50 AM, Berg, Eric <eric.berg at lehman.com> wrote:
>>> The problem that I'm having is that my cdbi mods in some of the apache
>>> instances are returning stale data in response to these requests.
>> If you're using InnoDB, check your isolation level as described here:
>> http://perl.apache.org/docs/1.0/guide/databases.html#Transactions_Not_Commi
>> tted_with_MySQL_InnoDB_Tables
>> If not try turning off the object index:
>> http://wiki.class-dbi.com/wiki/Common_problems#Old_data_due_to_object_index
>> - Perrin
> I had a similar problem recently with CDBI an my mod_perl app. I had a page  
> with lots of dynamically created images on it, some images depending on the 
> content of my session. The session is written (to Postgres) with "Select for 
> update" (Apache::Session) , yet, since CDBI recommends AutoCommit=>1 this is 
> completely ineffective. Normally this doesn't matter, but here a lot of 
> parallel requests led to some requests reading an "old" state of the session 
> or even overwriting the state of the "main" request (SessionAlwaysWrite=>1 ).
> I think the same problem can happen with any data written to the database when 
> you have asynchronous AJAX requests. 

Class::DBI doesn't recommend AutoCommit => 1, it just happens to be the usual
default. [1]  If it's giving you trouble, turn it off.

As a matter of fact, on Postgres it should be off by default.

[1] Blame me for that.  I made that default back when I bought the MySQL 3
<jedi_hand_wave>"you don't need transactions"</jedi_hand_wave> line.

I am somewhat preoccupied telling the laws of physics to shut up and sit down.
	-- Vaarsuvius, "Order of the Stick"

More information about the ClassDBI mailing list