Fix Remove Index Attempt (#1091)

This commit is contained in:
Yuhong Sun
2024-02-17 19:53:17 -08:00
committed by GitHub
parent e505486ca4
commit 6e8acdb20d

View File

@@ -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)