diff options
-rw-r--r-- | heat/db/sqlalchemy/api.py | 18 | ||||
-rw-r--r-- | heat/engine/service.py | 10 |
2 files changed, 11 insertions, 17 deletions
diff --git a/heat/db/sqlalchemy/api.py b/heat/db/sqlalchemy/api.py index dd3740a1f..f0489bb79 100644 --- a/heat/db/sqlalchemy/api.py +++ b/heat/db/sqlalchemy/api.py @@ -241,7 +241,7 @@ def resource_purge_deleted(context, stack_id): query = context.session.query(models.Resource) result = query.filter_by(**filters) attr_ids = [r.attr_data_id for r in result if r.attr_data_id is not None] - with context.session.begin(subtransactions=True): + with context.session.begin(): result.delete() if attr_ids: context.session.query(models.ResourcePropertiesData).filter( @@ -289,7 +289,7 @@ def resource_delete(context, resource_id): def resource_attr_id_set(context, resource_id, atomic_key, attr_id): session = context.session - with session.begin(subtransactions=True): + with session.begin(): values = {'attr_data_id': attr_id} _add_atomic_key_to_values(values, atomic_key) rows_updated = session.query(models.Resource).filter(and_( @@ -315,7 +315,7 @@ def resource_attr_id_set(context, resource_id, atomic_key, attr_id): def resource_attr_data_delete(context, resource_id, attr_id): session = context.session - with session.begin(subtransactions=True): + with session.begin(): resource = session.query(models.Resource).get(resource_id) attr_prop_data = session.query( models.ResourcePropertiesData).get(attr_id) @@ -437,7 +437,7 @@ def resource_exchange_stacks(context, resource_id1, resource_id2): def resource_data_delete(context, resource_id, key): result = resource_data_get_by_key(context, resource_id, key) session = context.session - with session.begin(subtransactions=True): + with session.begin(): session.delete(result) @@ -454,7 +454,7 @@ def resource_create_replacement(context, atomic_key, expected_engine_id=None): session = context.session try: - with session.begin(subtransactions=True): + with session.begin(): new_res = resource_create(context, new_res_values) update_data = {'replaced_by': new_res.id} update_data.update(existing_res_values) @@ -1237,7 +1237,7 @@ def software_deployment_update(context, deployment_id, values): def software_deployment_delete(context, deployment_id): deployment = software_deployment_get(context, deployment_id) session = context.session - with session.begin(subtransactions=True): + with session.begin(): session.delete(deployment) @@ -1603,7 +1603,7 @@ def _db_encrypt_or_decrypt_template_params( batch_size=batch_size) next_batch = list(itertools.islice(template_batches, batch_size)) while next_batch: - with session.begin(subtransactions=True): + with session.begin(): for raw_template in next_batch: try: if verbose: @@ -1686,7 +1686,7 @@ def _db_encrypt_or_decrypt_resource_prop_data_legacy( batch_size=batch_size) next_batch = list(itertools.islice(resource_batches, batch_size)) while next_batch: - with session.begin(subtransactions=True): + with session.begin(): for resource in next_batch: if not resource.properties_data: continue @@ -1733,7 +1733,7 @@ def _db_encrypt_or_decrypt_resource_prop_data( model=models.ResourcePropertiesData, batch_size=batch_size) next_batch = list(itertools.islice(rpd_batches, batch_size)) while next_batch: - with session.begin(subtransactions=True): + with session.begin(): for rpd in next_batch: if not rpd.data: continue diff --git a/heat/engine/service.py b/heat/engine/service.py index 62af50a95..5c02798d0 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -2320,18 +2320,12 @@ class EngineService(service.ServiceBase): try: for st in stacks: lock = stack_lock.StackLock(ctxt, st.id, self.engine_id) - lock.acquire() locks.append(lock) - sess = ctxt.session - sess.begin(subtransactions=True) - try: + lock.acquire() + with ctxt.session.begin(): for st in stacks: if not st.convergence: st.migrate_to_convergence() - sess.commit() - except Exception: - sess.rollback() - raise finally: for lock in locks: lock.release() |