Files
windmill/backend/windmill-api-embeddings
Ruben FiszelandClaude Opus 4.8 2318481f4f fix(embeddings): retry on failed init instead of disabling for a day (#10266)
* fix(embeddings): retry on failed init instead of disabling for a day

The embeddings init task treated failure and success identically, so a
transient error at startup left the embeddings DB uninitialized and every
/query_hub_scripts and /query_resource_types call returned "Embeddings db
not initialized":

- If ModelInstance::new() failed (a transient HuggingFace/network error
  surviving its own 5 download retries), the spawned task exited for good
  and embeddings never came up until the next process restart.
- If update_embeddings_db (hub fetch + fill_db) failed, the refresh loop
  still slept the full HUB_EMBEDDINGS_PULLING_INTERVAL_SECS (default 24h)
  before retrying.

Wrap model init in a retry loop, and make update_embeddings_db report
success so the refresh loop backs off by HUB_EMBEDDINGS_RETRY_INTERVAL_SECS
(default 60s, env-configurable) on failure instead of the full pulling
interval.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(embeddings): bound retry backoff to pulling interval

A fixed 60s retry loop was fine for the transient case but spun forever in
an environment where init can never succeed (air-gapped instance with
embeddings left enabled): an error log + HuggingFace fetch storm every ~60s
indefinitely, a behavior regression versus failing once and going quiet.

Decay the retry with exponential backoff capped at
HUB_EMBEDDINGS_PULLING_INTERVAL_SECS, resetting on success. A transient
blip still recovers within ~60s; a permanently-broken env settles into ~1
attempt per pulling interval (default: 1/day).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 23:36:28 +02:00
..