You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Eric W. Bates" <er...@vineyard.net> on 2005/04/14 20:46:39 UTC

data persistence problem with Class::DBI

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm a list newbie; so I apologize if this question has been hashed
before and my google queries were simply badly written.

We're using Class::DBI in a mod_perl context and all is working quite
well.  However, sometimes a CDBI object persists with old data after the
record has been updated. Hitting apache with a 'graceful' fixes it.

We have separate handlers for displaying and editing the records; so I'm
assuming that the copy of the object used in the display handler is
persisting between accesses in spite of the handler's code
reinstantiating the object with a retrieve().

Anybody dealt with this?

Think it's a feature of Ima::DBI or some other part of Class::DBI?

Thanks for your time.

- --
Eric W. Bates
ericx@vineyard.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCXrqPD1roJTQ4LlERAluzAKC6ooZjySzcVx2lylWlkKQ9PhU3PACcCHbA
LZu4045l3k0n2yOoHQ7A//k=
=DScF
-----END PGP SIGNATURE-----

Re: data persistence problem with Class::DBI

Posted by "Eric W. Bates" <er...@vineyard.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Paul Johnson wrote:
> On Thu, Apr 14, 2005 at 02:46:39PM -0400, Eric W. Bates wrote:
> 
> 
>>We're using Class::DBI in a mod_perl context and all is working quite
>>well.  However, sometimes a CDBI object persists with old data after the
>>record has been updated. Hitting apache with a 'graceful' fixes it.
>>
>>We have separate handlers for displaying and editing the records; so I'm
>>assuming that the copy of the object used in the display handler is
>>persisting between accesses in spite of the handler's code
>>reinstantiating the object with a retrieve().
>>
>>Anybody dealt with this?
>>
>>Think it's a feature of Ima::DBI or some other part of Class::DBI?
> 
> 
> Take a look at UNIQUENESS OF OBJECTS IN MEMORY in the Class:DBI manpage.
> I had a very similar problem.  In my case I think the object is
> persisting because it is being accessed from a TT2 page and I suspect
> TT2 is creating a closure, but I haven't tracked the reasons fully.

You are correct.  We are using TT2.

> I fixed the problem with a call to clear_object_index at the start of
> the handler.  I'd be pleased to hear of a slightly more subtle approach
> though.

Thanks. I'll let you know how that works out.

- --
Eric W. Bates
ericx@vineyard.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCXuibD1roJTQ4LlERAuyUAKDIpip4+ysaqbuDs5jtKrcMXHTcKACgmgFL
G5Ik3UqTdZGxq74GEIkzNIc=
=SMIQ
-----END PGP SIGNATURE-----

Re: data persistence problem with Class::DBI

Posted by Paul Johnson <pa...@pjcj.net>.
On Thu, Apr 14, 2005 at 02:46:39PM -0400, Eric W. Bates wrote:

> We're using Class::DBI in a mod_perl context and all is working quite
> well.  However, sometimes a CDBI object persists with old data after the
> record has been updated. Hitting apache with a 'graceful' fixes it.
> 
> We have separate handlers for displaying and editing the records; so I'm
> assuming that the copy of the object used in the display handler is
> persisting between accesses in spite of the handler's code
> reinstantiating the object with a retrieve().
> 
> Anybody dealt with this?
> 
> Think it's a feature of Ima::DBI or some other part of Class::DBI?

Take a look at UNIQUENESS OF OBJECTS IN MEMORY in the Class:DBI manpage.
I had a very similar problem.  In my case I think the object is
persisting because it is being accessed from a TT2 page and I suspect
TT2 is creating a closure, but I haven't tracked the reasons fully.

I fixed the problem with a call to clear_object_index at the start of
the handler.  I'd be pleased to hear of a slightly more subtle approach
though.

-- 
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

Re: data persistence problem with Class::DBI

Posted by Michael Peters <mp...@plusthree.com>.
Eric W. Bates wrote:
> I'm a list newbie; so I apologize if this question has been hashed
> before and my google queries were simply badly written.
> 
> We're using Class::DBI in a mod_perl context and all is working quite
> well.  However, sometimes a CDBI object persists with old data after the
> record has been updated. Hitting apache with a 'graceful' fixes it.
> 
> We have separate handlers for displaying and editing the records; so I'm
> assuming that the copy of the object used in the display handler is
> persisting between accesses in spite of the handler's code
> reinstantiating the object with a retrieve().

mod_perl doesn't make your objects persistent unless you create some
sort of session and store your objects in it, or you have a problem in
your code (closure, global, etc).

Besides issues with your code, it can also be database related. Are you
using MySQL with InnoDB tables? then it could be your transaction
isolation level.

You might have a look at the wiki page for some more details on using
Class::DBI with mod_perl (sorry it's down at the moment)


> 
> Anybody dealt with this?
> 
> Think it's a feature of Ima::DBI or some other part of Class::DBI?
> 
> Thanks for your time.
> 
> --
> Eric W. Bates
> ericx@vineyard.net

-- 
Michael Peters
Developer
Plus Three, LP