feat: api post model embedding processes#514
Closed
irumvanselme wants to merge 3 commits into
Closed
Conversation
Comment on lines
+113
to
+123
| totalDocuments += await this.pushEntitiesToQueue(modelId, entitySource.entityType, entitySource.findAll()); | ||
| } | ||
|
|
||
| // 5. Update the embedding process state with the total number of documents that were pushed to the queue. | ||
| return this.embeddingProcessStateRepository.update(embeddingProcessState.id, { | ||
| status: ModelInfoApiSpecs.ModelInfo.EmbeddingProcessStates.Enums.Status.IN_PROGRESS, | ||
| totalDocuments, | ||
| }); | ||
| } catch (e) { | ||
| throw new Error(`Failed to trigger embedding process for model ${modelId}.`, { cause: e }); | ||
| } |
There was a problem hiding this comment.
Bug: If pushing tasks to the SQS queue fails, the PENDING EmbeddingProcessState is not cleaned up, blocking all future embedding attempts for that model.
Severity: HIGH
Suggested Fix
In the catch block within the triggerEmbeddingProcess function (around line 121), add logic to delete the EmbeddingProcessState document that was created at the beginning of the process. This ensures that a failed attempt cleans up after itself and doesn't block subsequent runs.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: backend/src/embeddings/embeddingProcess/embeddingProcess.service.ts#L87-L123
Potential issue: The process creates an `IEmbeddingProcessState` document with a
`PENDING` status before pushing tasks to the SQS queue. If any `pushTaskToQueue` call
fails, which can happen due to network issues or SQS errors, the exception is caught but
the state document is not deleted. This orphaned `PENDING` state will cause subsequent
attempts to trigger embeddings for the same model to fail with an
`EmbeddingProcessAlreadyRunningError`. This effectively locks the model from being
re-embedded until the state is manually cleared from the database.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes