Skip to content

Commit

Permalink
Work around a DB consistency bug on macOS
Browse files Browse the repository at this point in the history
Mitigates the impact of python/cpython#91228
  • Loading branch information
offbyone committed Oct 10, 2024
1 parent 89f8fc5 commit aa13325
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion code/planet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,16 @@ def __init__(self, planet, url):
self.exclude = None
self.next_order = "0"
self.cache_read()
self.cache_read_entries()
try:
self.cache_read_entries()
except SystemError:
# This can be triggered by https://github.com/python/cpython/issues/91228 (I think!) on
# some DBs, but really, only on macOS. While that is not how this is run in production,
# it's kinda nice to test. So, we catch the failure here, and flush the etag / modified
# fields so that update always works.
log.error(f"DB corruption for {url}; reloading the feed")
self.url_etag = None
self.url_modified = None

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

def cache_read_entries(self):
"""Read entry information from the cache."""

keys = self._cache.keys()
for key in keys:
if key.find(" ") != -1:
Expand Down

0 comments on commit aa13325

Please sign in to comment.