ZODB drops _v_ attributes.
Hi. I use the standalone ZODB. When I create persistent objects containing _v_ (volatile attributes), and access them at an extremely high rate(reading and using), they sometimes lose their _v_ attibutes. This occures at random intervals, and can be reproduced. After a few seconds of operation, I suddenly get an error like: ============================================================ Traceback (most recent call last): File "C:\Development\Module.py", line 220, in remPacket self._v_messages.loopMembersWithIds(packet.getMessageIds(), self._delivered) AttributeError: _v_messages ============================================================ The object containing the _v_messages worked fine prior to the error. Can somebody tell me what I need to do the avoid this? Herman. == Download ringtones, logos and picture messages at Ananzi Mobile Fun. http://www.ananzi.co.za/cgi-bin/goto.pl?mobile
On Tuesday 08 April 2003 1:27 pm, ZOPE Developer wrote:
Hi.
I use the standalone ZODB.
When I create persistent objects containing _v_ (volatile attributes), and access them at an extremely high rate(reading and using), they sometimes lose their _v_ attibutes.
Thats what volatile means!
Can somebody tell me what I need to do the avoid this?
To stop the attribute value disappearing? Make it non-volatile. To detect the situation and avoid the AttributeError? Use hasattr, or set a shadow class attribute with a null value. -- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson
Just a question in general on this subject: When I retrieve an object out of a ZODB and that object instantiates some volatile variables. How long can I expect that object to hang on to those volatile variables? Shouldn't they last at least until I let go of my reference to the object? Thanks Etienne At 01:48 PM 4/8/2003 +0100, Toby Dickenson wrote:
On Tuesday 08 April 2003 1:27 pm, ZOPE Developer wrote:
Hi.
I use the standalone ZODB.
When I create persistent objects containing _v_ (volatile attributes), and access them at an extremely high rate(reading and using), they sometimes lose their _v_ attibutes.
Thats what volatile means!
Can somebody tell me what I need to do the avoid this?
To stop the attribute value disappearing? Make it non-volatile.
To detect the situation and avoid the AttributeError? Use hasattr, or set a shadow class attribute with a null value.
-- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Tuesday 08 April 2003 2:03 pm, Etienne Labuschagne wrote:
Just a question in general on this subject:
When I retrieve an object out of a ZODB and that object instantiates some volatile variables. How long can I expect that object to hang on to those volatile variables?
The cache is flushed at the end of a transaction, and can be flushed manually. At that time it currently uses a strict least-recently-used eviction policy, but that is not guaranteed in future. The volatile attribute is then lost - the same as all of that object's attributes. The only difference between volatile and non-volatile is that this attribute can not be recreated if the object is subsequently reactivated.
Shouldn't they last at least until I let go of my reference to the object?
It has to keep the object in memory. Your reference has to point somewhere. If your object is evicted from cache then it loses its attributes and turns into a ghost. Doing anything else would mean that one accidental reference, or a circular reference, could keep a huge tree of objects in memory indefinitely. -- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson
Ok, hopefully the last question. Normally (in my code anyway) I will instantiate the volatiles with the setstate method (in Zope programming anyway). 1. Is setstate Zope specific, or is it called for any ZODB persistent object (i.e. a stand-alone ZODB application)? 2. If my object turns into a ghost and after a while I start using it again, will setstate be called again (thus initialising the _v_'s again) or must I check manually that my _v_'s are still there, and do something if not? 3. Is there a way to force the refresh of an in-memory object so that setstate is called again (obviously, I can probably just call setstate manually by myself? But again - that needs a state parameter. . .) Thanks for your very insightful answers so far! Etienne At 03:51 PM 4/8/2003 +0100, Toby Dickenson wrote:
On Tuesday 08 April 2003 2:03 pm, Etienne Labuschagne wrote:
Just a question in general on this subject:
When I retrieve an object out of a ZODB and that object instantiates some volatile variables. How long can I expect that object to hang on to those volatile variables?
The cache is flushed at the end of a transaction, and can be flushed manually. At that time it currently uses a strict least-recently-used eviction policy, but that is not guaranteed in future.
The volatile attribute is then lost - the same as all of that object's attributes. The only difference between volatile and non-volatile is that this attribute can not be recreated if the object is subsequently reactivated.
Shouldn't they last at least until I let go of my reference to the object?
It has to keep the object in memory. Your reference has to point somewhere.
If your object is evicted from cache then it loses its attributes and turns into a ghost. Doing anything else would mean that one accidental reference, or a circular reference, could keep a huge tree of objects in memory indefinitely.
-- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Tuesday 08 April 2003 4:14 pm, Etienne Labuschagne wrote:
Normally (in my code anyway) I will instantiate the volatiles with the setstate method (in Zope programming anyway).
1. Is setstate Zope specific, or is it called for any ZODB persistent object (i.e. a stand-alone ZODB application)?
it is not zope specific
2. If my object turns into a ghost and after a while I start using it again, will setstate be called again (thus initialising the _v_'s again) or must I check manually that my _v_'s are still there, and do something if not?
It will be called.
3. Is there a way to force the refresh of an in-memory object so that setstate is called again (obviously, I can probably just call setstate manually by myself? But again - that needs a state parameter. . .)
my_object._p_deactivate() will turn my_object into a ghost. setstate will be called on the next attribute access -- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson
Thanks for the response. I basically store events and locks--ie non-picklable types-- in my _v_ variables. I never destroy or loose a reference to the container object. They just suddenly out of nowhere drop, the volatile attributes. The same operation that caused the exception, worked prior to the exception, nothing changed---wel, except the missing _v_ attributes went missing...that I cannot explain. Maybe volatile attributes are too volatile??? Thanks Herman On Tue, 8 Apr 2003 13:48:58 +0100 Toby Dickenson <tdickenson@geminidataloggers.com> wrote:
On Tuesday 08 April 2003 1:27 pm, ZOPE Developer wrote:
Hi.
I use the standalone ZODB.
When I create persistent objects containing _v_ (volatile attributes), and access them at an extremely high rate(reading and using), they sometimes lose their _v_ attibutes.
Thats what volatile means!
Can somebody tell me what I need to do the avoid this?
To stop the attribute value disappearing? Make it non-volatile.
To detect the situation and avoid the AttributeError? Use hasattr, or set a shadow class attribute with a null value.
-- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson
== Download ringtones, logos and picture messages at Ananzi Mobile Fun. http://www.ananzi.co.za/cgi-bin/goto.pl?mobile
participants (3)
-
Etienne Labuschagne -
Toby Dickenson -
ZOPE Developer