OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

fetchExistingChunkVectors swallows failures at DEBUG, silently downgrading a docVersion migration to a full re-embed

Open fmcardoso opened this issue 2 months ago • 0 comments

OpenSearchVectorService.fetchExistingChunkVectors swallows every failure at DEBUG and returns an empty map:

} catch (Exception e) {
  LOG.debug("Failed to fetch existing chunk vectors for {}: {}", parentId, e.getMessage());
}
return vectors;

Its caller treats an incomplete map as "vectors unavailable" and falls back to a full re-embed:

Map<Integer, float[]> vectors = fetchExistingChunkVectors(chunkIndexName, parentId, header.chunkCount());
if (vectors.size() != header.chunkCount()) {
  LOG.info("Chunk docVersion rebuild for {} recovered {}/{} cached vectors; re-embedding", ...);
  return VectorDocBuilder.fromEntity(entity, embeddingClient);
}

Why it matters

Vector reuse is the whole reason a CHUNK_DOC_VERSION migration is cheap: the content fingerprint is unchanged, so the stored vectors are reusable and the rebuild should cost no embedding calls. When the mget fails, that guarantee is lost and every affected entity re-embeds instead.

Two consequences:

  1. Unbudgeted embedding cost. A migration expected to be free becomes a full embedding pass over the catalogue.
  2. Under-completed migrations. If the embedding provider is rate-limited or unavailable, the re-embed raises EmbeddingUnavailableException, the chunk write is skipped, and the entity is simply left un-migrated.

Why it is hard to notice

The fallback itself is logged at INFO, so this is not fully silent — but the line reads identically whether the cause is a genuinely absent vector or a cluster-wide failure to read _source:

Chunk docVersion rebuild for <id> recovered 0/80 cached vectors; re-embedding

The distinguishing information — the exception — is at DEBUG, which is not usually enabled ahead of time. Diagnosing it after an embedding-cost spike means correlating against logs that no longer exist.

Not theoretical

Reproduced on a local OpenSearch 3.4 cluster with knn.derived_source.enabled: the HNSW .vec file entered an already_closed_exception state, which failed every _source read on the chunk index — including this mget. Ordinary _count and knn queries still worked, so the index looked healthy. Any condition that breaks _source reads on the chunk index produces the same outcome. A node restart cleared it.

Proposed change

Raise the catch to LOG.warn and include the exception, so the reason travels with the fallback:

} catch (Exception e) {
  LOG.warn("Failed to fetch existing chunk vectors for {}; will re-embed: {}", parentId, e.getMessage(), e);
}

Optionally, distinguish "no vectors found" (expected for a new entity) from "the fetch itself failed" (unexpected) so the INFO fallback line can say which it was.

Context

Surfaced while reviewing #32612 / #32609, which bump CHUNK_DOC_VERSION 3 → 4. That bump makes this path load-bearing on the next Search Reindex, which is when the cost would be incurred.

fmcardoso avatar Sep 07 '26 14:09 fmcardoso