Harden vectorization task against per-package failures

A single failing package used to kill its whole worker thread silently
because only Vectorizer::Error was rescued per package. Now every
StandardError is caught and logged with class and backtrace, and the
embedding write is narrowed to update_column(:embedding) so the task
only ever issues a minimal UPDATE - it cannot touch any other column
or fire model callbacks. Progress stats no longer serialize database
writes through the mutex.
This commit is contained in:
Christoph Haas 2026-08-23 00:11:52 +02:00
parent 4d07f43a2e
commit 3550a4e2e2
2 changed files with 18 additions and 13 deletions

View file

@ -56,13 +56,12 @@ class Package < ApplicationRecord
# Compute and store the embedding vector for this package by asking
# the external vector service. Raises Vectorizer::Error on failure.
# Returns true if the vector was saved.
# Returns true if a vector was saved.
def update_embedding!
text = embedding_text
return false if text.blank?
self.embedding = Vectorizer.embed(text)
save!
update_column(:embedding, Vectorizer.embed(text))
end
# Return a relation of packages whose stored embeddings are closest to