Mercurial > evolve
changeset 4006:21aee0a596ce
sqlcache: also ignore integrity error
integrity error can happens when multiple client tries to warm similar cache.
Given we leave multiple hole in the cache that can be warmed by anyone, this is
harder to avoid that we would like. We simply catch the error in this case.
Someone will warm the missing entry later.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 27 Aug 2018 00:35:51 +0200 |
parents | d85556dd18b5 |
children | d468db69f9a0 |
files | hgext3rd/evolve/obsdiscovery.py hgext3rd/evolve/stablerangecache.py |
diffstat | 2 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obsdiscovery.py Mon Aug 27 00:28:19 2018 +0200 +++ b/hgext3rd/evolve/obsdiscovery.py Mon Aug 27 00:35:51 2018 +0200 @@ -575,7 +575,14 @@ def _save(self, repo): try: return self._trysave(repo) - except sqlite3.OperationalError as exc: + except (sqlite3.OperationalError, sqlite3.IntegrityError) as exc: + # Catch error that may arise under stress + # + # operational error catch read-only and locked database + # IntegrityError catch Unique constraint error that may arise + if '_con' in vars(self): + del self._con + self._new.clear() repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc) def _trysave(self, repo):
--- a/hgext3rd/evolve/stablerangecache.py Mon Aug 27 00:28:19 2018 +0200 +++ b/hgext3rd/evolve/stablerangecache.py Mon Aug 27 00:35:51 2018 +0200 @@ -224,7 +224,14 @@ def _save(self, repo): try: return self._trysave(repo) - except sqlite3.OperationalError as exc: + except (sqlite3.OperationalError, sqlite3.IntegrityError) as exc: + # Catch error that may arise under stress + # + # operational error catch read-only and locked database + # IntegrityError catch Unique constraint error that may arise + if '_con' in vars(self): + del self._con + self._unsavedsubranges.clear() repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc) def _trysave(self, repo):