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

Commit 0f085f3

Browse files
committed
rollback the session after UNIQUE constraint failed exception
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]>
1 parent 1009c49 commit 0f085f3

File tree

1 file changed

+5
-1
lines changed
  • docker_registry/lib/index

1 file changed

+5
-1
lines changed

docker_registry/lib/index/db.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ def _generate_index(self, session):
113113
session.add(Version(id=self.version))
114114
for repository in self._walk_storage(store=store):
115115
session.add(Repository(**repository))
116-
session.commit()
116+
try:
117+
session.commit()
118+
except Exception as e:
119+
logger.exception(str(e))
120+
session.rollback()
117121

118122
@retry
119123
def _handle_repository_created(

0 commit comments

Comments
 (0)