Merge "Database session need to rollback after duplication"

This commit is contained in:
Zuul 2017-10-30 12:38:30 +00:00 committed by Gerrit Code Review
commit 28485327f7
1 changed files with 2 additions and 0 deletions

View File

@ -393,6 +393,7 @@ class BaseRepo(object):
raise exception.Invalid(msg)
LOG.debug("Begin create from...")
session = self.get_session(session)
start = time.time() # DEBUG
# Validate the attributes before we go any further. From my
@ -406,6 +407,7 @@ class BaseRepo(object):
LOG.debug("Saving entity...")
entity.save(session=session)
except db_exc.DBDuplicateEntry as e:
session.rollback()
LOG.exception('Problem saving entity for create')
error_msg = re.sub('[()]', '', str(e.args))
raise exception.ConstraintCheck(error=error_msg)