We using block 'with session.begin()' to organize some operations in
one transaction. session.begin() returns a transaction instance, then
does some operations, and will commit or rollback automatically
before leaving the block. ModelBase.save() always submit a commit,
and that is not expected.
When we get a persistent object from database, we just modify the
object inside of block 'with session.begin()' and sqlalchemy will
update it,don't need method session.add() or ModelBase.save()
Reviewed: https:/ /review. openstack. org/46253 github. com/openstack/ nova/commit/ 037d1e9b1b89fb0 a969b1b02ee4c74 550b7864b0
Committed: http://
Submitter: Jenkins
Branch: master
commit 037d1e9b1b89fb0 a969b1b02ee4c74 550b7864b0
Author: Chang Bo Guo <email address hidden>
Date: Thu Sep 12 04:27:40 2013 -0700
Don't use ModelBase.save() inside of transaction
We using block 'with session.begin()' to organize some operations in
one transaction. session.begin() returns a transaction instance, then
does some operations, and will commit or rollback automatically
before leaving the block. ModelBase.save() always submit a commit,
and that is not expected.
When we get a persistent object from database, we just modify the
object inside of block 'with session.begin()' and sqlalchemy will
update it,don't need method session.add() or ModelBase.save()
Fixes bug #1224429
Change-Id: I8af3fd4b62a915 833bf303b6892d4 32043fb57a9