Skip to content

Commit

Permalink
Attempt full reindex upon incremental failure, fixes #554.
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Nov 29, 2024
1 parent fe6df26 commit de6ae36
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions yente/search/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,22 @@ async def index_entities(
try:
docs = iter_entity_docs(updater, next_index)
await provider.bulk_index(docs)
except YenteIndexError as exc:
except (YenteIndexError, Exception) as exc:
detail = getattr(exc, "detail", str(exc))
log.exception(
"Indexing error: %s" % exc.detail,
"Indexing error: %s" % detail,
dataset=dataset.name,
index=next_index,
)
aliases = await provider.get_alias_indices(alias)
if next_index not in aliases:
log.warn("Deleting partial index", index=next_index)
await provider.delete_index(next_index)
if updater.is_incremental and not force:
# This is tricky: try again with a full reindex if the incremental
# indexing failed
log.warn("Retrying with full reindex", dataset=dataset.name)
return await index_entities(provider, dataset, force=True)
raise exc

await provider.refresh(index=next_index)
Expand Down

0 comments on commit de6ae36

Please sign in to comment.