'with session.begin()' makes 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/78141 /git.openstack. org/cgit/ openstack/ cinder/ commit/ ?id=13387c01390 e70c9d7811760e6 03e6306d6d7ea7
Committed: https:/
Submitter: Jenkins
Branch: master
commit 13387c01390e70c 9d7811760e603e6 306d6d7ea7
Author: ChangBo Guo(gcb) <email address hidden>
Date: Wed Mar 5 17:00:58 2014 +0800
Don't use ModelBase.save() inside of transaction
'with session.begin()' makes some operations in one transaction. save() always submit a commit, and that is not expected.
session.begin() returns a transaction instance, then does some operations,
and will commit or rollback automatically before leaving the block.
ModelBase.
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().
Closes-Bug: #1224429 3945d92e57680d5 8e7ae356a67
Change-Id: I4af58e98b2783d