From 015f415b71b50065604eeeb03d7c906c2549f6c9 Mon Sep 17 00:00:00 2001 From: rkuo-danswer Date: Mon, 29 Jul 2024 20:12:58 -0700 Subject: [PATCH] avoid reindexing secondary indexes after they succeed (#1971) --- backend/danswer/background/update.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/danswer/background/update.py b/backend/danswer/background/update.py index 8150d7c18..8712898ac 100755 --- a/backend/danswer/background/update.py +++ b/backend/danswer/background/update.py @@ -68,20 +68,26 @@ def _should_create_new_indexing( return False # When switching over models, always index at least once - if model.status == IndexModelStatus.FUTURE and not last_index: - if connector.id == 0: # Ingestion API - return False + if model.status == IndexModelStatus.FUTURE: + if last_index: + # secondary indexes should not index again after success + # or else the model will never be able to swap + if last_index.status == IndexingStatus.SUCCESS: + return False + else: + if connector.id == 0: # Ingestion API + return False return True # If the connector is disabled, don't index - # NOTE: during an embedding model switch over, we ignore this - # and index the disabled connectors as well (which is why this if - # statement is below the first condition above) + # NOTE: during an embedding model switch over, the following logic + # is bypassed by the above check for a future model if connector.disabled: return False if connector.refresh_freq is None: return False + if not last_index: return True