hgext3rd/evolve/stablerangecache.py
changeset 4011 3cb41bf56f16
parent 4010 4c2fcd53c601
child 4013 434398b37e16
--- a/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 11:33:09 2018 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 11:40:32 2018 +0200
@@ -177,11 +177,19 @@
         cache = self._subrangescache
         if rangeid not in cache and rangeid[0] <= self._ondisktiprev and self._con is not None:
             value = None
-            result = self._con.execute(_queryrange, rangeid).fetchone()
-            if result is not None: # database know about this node (skip in the future?)
-                value = self._con.execute(_querysubranges, rangeid).fetchall()
-            # in memory caching of the value
-            cache[rangeid] = value
+            try:
+                result = self._con.execute(_queryrange, rangeid).fetchone()
+                if result is not None: # database know about this node (skip in the future?)
+                    value = self._con.execute(_querysubranges, rangeid).fetchall()
+                # in memory caching of the value
+                cache[rangeid] = value
+            except sqlite3.OperationalError:
+                # something is wrong with the sqlite db
+                # Since this is a cache, we ignore it.
+                if '_con' in vars(self):
+                    del self._con
+                self._unsavedsubranges.clear()
+
         return cache.get(rangeid)
 
     def _setsub(self, rangeid, value):