Hello!  I'm iterating over a session to look at all the objects:

for obj in session:
  do_something_cool(obj)

Yesterday this caused what looks like a deadlock in SQLAlchemy code.  Here
is the stack I grabbed using gdb:

   1. /python2.5/sqlalchemy/orm/session.py:1353 (Session.__iter__)
   2. /python2.5/sqlalchemy/orm/identity.py:184 (WeakInstanceDict.values)
   3. /python2.5/sqlalchemy/orm/identity.py:188 (WeakInstanceDict.itervalues
   ) ** self._remove_mutex.acquire()
   4. /python2.5/sqlalchemy/orm/state.py:501 (
   MutableAttrInstanceState.__resurrect)
   5. /python2.5/sqlalchemy/orm/attributes.py:925 (Events.run)
   6. /python2.5/sqlalchemy/orm/mapper.py:2424 (_event_on_resurrect)
   7. /python2.5/sqlalchemy/util.py:953 (OrderedSet.__iter__)
   8. /python2.5/sqlalchemy/orm/state.py:477 (
   MutableAttrInstanceState._cleanup)
   9. /python2.5/sqlalchemy/orm/identity.py:139A
(WeakInstanceDict.remove)** self._remove_mutex.acquire
   ()

I'm running SQLAlchemy 0.6.5.  Is this a known issue or am I doing something
wrong?

On a somewhat related note, am experiencing the issue where lots of objects
in a session significantly reduces performance.  It appears I am
experiencing the penalty for using MutableTypes on objects described here:
http://readthedocs.org/docs/sqlalchemy/en/latest/core/types.html#base-type-api.
The doc states:

In order to detect changes, the ORM must create a copy of the value when it
is first accessed, so that changes to the current value can be compared
against the “clean” database-loaded value. Additionally, when the ORM checks
to see if any data requires flushing, it must scan through all instances in
the session which are known to have “mutable” attributes and compare the
current value of each one to its “clean” value.

It doesn't seem like I should have to pay this penalty because with my type
I actually know when any updates occur.  The type just supports
models.mutable_value.update(data).  Is there a way to notify the
model/session that the value has been updated when someone calls update, so
the full scan of all instances is not needed?  Do I need to rewrite the
update function to translate models.mutable_value.update(data) to actually
generate models.mutable_value = new_mutable_value or is there a better way
to do this?

Thanks for any help!

  -Lenza

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to