Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
rollback the session after UNIQUE constraint failed exception
Browse files Browse the repository at this point in the history
Here is the error message:
InvalidRequestError: This Session's transaction has been rolled
back due to a previous exception during flush. To begin a new
transaction with this Session, first issue Session.rollback().
Original exception was: (IntegrityError) UNIQUE constraint failed:
version.id u'INSERT INTO version (id) VALUES (?)' (1,)

Signed-off-by: Harrison Feng <[email protected]>
  • Loading branch information
harrisonfeng committed Jan 29, 2015
1 parent 1009c49 commit 0f085f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docker_registry/lib/index/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def _generate_index(self, session):
session.add(Version(id=self.version))
for repository in self._walk_storage(store=store):
session.add(Repository(**repository))
session.commit()
try:
session.commit()
except Exception as e:
logger.exception(str(e))
session.rollback()

@retry
def _handle_repository_created(
Expand Down

0 comments on commit 0f085f3

Please sign in to comment.