Skip to content

Commit aa13325

Browse files
committed
Work around a DB consistency bug on macOS
Mitigates the impact of python/cpython#91228
1 parent 89f8fc5 commit aa13325

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

code/planet/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,16 @@ def __init__(self, planet, url):
578578
self.exclude = None
579579
self.next_order = "0"
580580
self.cache_read()
581-
self.cache_read_entries()
581+
try:
582+
self.cache_read_entries()
583+
except SystemError:
584+
# This can be triggered by https://github.com/python/cpython/issues/91228 (I think!) on
585+
# some DBs, but really, only on macOS. While that is not how this is run in production,
586+
# it's kinda nice to test. So, we catch the failure here, and flush the etag / modified
587+
# fields so that update always works.
588+
log.error(f"DB corruption for {url}; reloading the feed")
589+
self.url_etag = None
590+
self.url_modified = None
582591

583592
if planet.config.has_section(url):
584593
for option in planet.config.options(url):
@@ -618,6 +627,7 @@ def __iter__(self):
618627

619628
def cache_read_entries(self):
620629
"""Read entry information from the cache."""
630+
621631
keys = self._cache.keys()
622632
for key in keys:
623633
if key.find(" ") != -1:

0 commit comments

Comments
 (0)