ConcurrentModificationError in 0.4.2a when flushing a session

Issue #922 resolved
Former user created an issue

The attached test case fails in 0.4.2a. It had previously been passing on the 0.4.2 development trunk. I did a binary search on the trunk changesets, and found that the failure started to appear in r3940. The test case creates two tables, named parents and children, with a many-to-many relationship between them. One of the child objects is selected, the corresponding parents are cloned and the selected child object is removed from the cloned parents. When the session is flushed the following traceback occurs in 0.4.2a:

Traceback (most recent call last): File "test.py", line 135, in <module> test() File "test.py", line 99, in test session.flush() File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/session.py", line 693, in flush self.uow.flush(self, objects) File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 215, in flush flush_context.execute() File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 437, in execute UOWExecutor().execute(self, tasks) File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 927, in execute self.execute_save_steps(trans, task) File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 945, in execute_save_steps self.execute_dependencies(trans, task, False) File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 956, in execute_dependencies self.execute_dependency(trans, dep, False) File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 939, in execute_dependency dep.execute(trans, isdelete) File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 892, in execute self.processor.process_dependencies(self.targettask, for elem in self.targettask.polymorphic_tosave_elements if elem.state is not None, trans, delete=False) File "/home/david/lib/python2.5/SQLAlchemy-0.4.2a-py2.5.egg/sqlalchemy/orm/dependency.py", line 438, in process_dependencies raise exceptions.ConcurrentModificationError("Deleted rowcount %d does not match number of objects deleted %d" % (result.rowcount, len(secondary_delete))) sqlalchemy.exceptions.ConcurrentModificationError: Deleted rowcount 0 does not match number of objects deleted 2

This error does not occur in r3939.

Comments (3)

  1. Mike Bayer repo owner

    this is a pretty serious issue, and like all serious issues caused by a one liner, and is fixed in e8feacf1db658ecccf7bb1d1688662e701ad37f5. It only occurs when assigning a collection to an attribute (i.e. foo.bar = [somecollection](somecollection)) where that attribute already has some post-commit/load history on it. Its likely that I'll put out 0.4.2b today for this fix. If you can give the 4023 a test drive today that would be great otherwise its just going to go out (we're just doing lettered releases on this one since a lot changed in 0.4.2).

  2. Log in to comment