From 6e8acdb20d758faf9f723ff8ecaba6a6f935de34 Mon Sep 17 00:00:00 2001 From: Yuhong Sun Date: Sat, 17 Feb 2024 19:53:17 -0800 Subject: [PATCH] Fix Remove Index Attempt (#1091) --- backend/danswer/db/index_attempt.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/backend/danswer/db/index_attempt.py b/backend/danswer/db/index_attempt.py index 7e08c167b95..7d8b38959b9 100644 --- a/backend/danswer/db/index_attempt.py +++ b/backend/danswer/db/index_attempt.py @@ -244,20 +244,15 @@ def cancel_indexing_attempts_for_connector( db_session: Session, include_secondary_index: bool = False, ) -> None: - subquery = select(EmbeddingModel.id).where( - EmbeddingModel.status != IndexModelStatus.FUTURE - ) - - stmt = ( - update(IndexAttempt) - .where( - IndexAttempt.connector_id == connector_id, - IndexAttempt.status == IndexingStatus.NOT_STARTED, - ) - .values(status=IndexingStatus.FAILED) + stmt = delete(IndexAttempt).where( + IndexAttempt.connector_id == connector_id, + IndexAttempt.status == IndexingStatus.NOT_STARTED, ) if not include_secondary_index: + subquery = select(EmbeddingModel.id).where( + EmbeddingModel.status != IndexModelStatus.FUTURE + ) stmt = stmt.where(IndexAttempt.embedding_model_id.in_(subquery)) db_session.execute(stmt)