OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

Reindex bulk sink silently assigns identical embedding vectors to distinct documents when using custom OpenAI-compatible embedding provider under concurrent load

Open AuTyi opened this issue 5 months ago • 1 comments

Affected module

Search / Discovery

Describe the bug

Component: openmetadata-service — SearchIndexApp / BulkExecutor / OpenSearchBulkSink (package org.openmetadata.service.apps.bundles.searchIndex) Version: 1.13.1 Related: #26574 (OpenAI embedding concurrency control — rate-limit storm prevention, does not appear to address this symptom)


Environment

  • OpenShift, air-gapped enterprise deployment, no external internet access
  • Search backend: OpenSearch 3.2.0
  • Embedding provider: custom OpenAI-compatible sidecar (FastAPI + sentence-transformers, model paraphrase-multilingual-MiniLM-L12-v2, 384-dim), used in place of DJL because DJL is non-functional on Alpine/musl base images in this environment
  • Reindex concurrency: BulkExecutor threads=10, queue=1000 (log-confirmed default, not present as configurable env var or Helm value in the shipped chart)
  • Index: table_search_index, ~50,000+ table documents, single shard, single replica

Description

During a full reindex with vector embeddings enabled, the reindex pipeline can assign an embedding vector generated for one document to a different, unrelated document. Both documents retain their own distinct textToEmbed content and distinct fingerprint values, but end up storing byte-identical 384-dimension vectors in the embedding field.

This does not raise any error or failure count. All observed PartitionWorker completion logs for the affected entity type report failed:0.


Evidence

  1. Direct OpenSearch _doc GET on two table documents confirms identical embedding arrays despite different fingerprint and textToEmbed values:

    Document A (_id: ff1893fd-f9f1-476a-9794-ab2fab07e3a5) fingerprint: 3a6f7f5877769ad3fa0966d20c8b7fb4 textToEmbed: "table 00170f55e8b249cfaa834a09011d1a2e_2277f3f1-078e-4686-b1f8- b26c665aa594. Tagged as Company ESO, Company IGNITIS. Columns include Column1...Column19"

    Document B (_id: 3988a1b4-cde6-48f2-be4a-fdbe8293264e) fingerprint: 8a11d641d2cc96cbefc8ec62b6452929 textToEmbed: "table 000be2bafe4d49218150f23c4837ee73_13d83cb7-5462-4bb1- b240-ea8289b18ea5. Tagged as Company ESO, Company IGNITIS. Columns include Column1...Column19"

    Both documents' embedding field: identical 384-float array (verified by direct array comparison, not just visual inspection).

  2. Calling the embedding service directly with each document's exact textToEmbed string produces two DIFFERENT vectors (confirmed via /v1/embeddings endpoint, first-5-values diff observed). This rules out the embedding service itself returning a static/cached response — the defect is in the reindex pipeline's handling of the response, not in embedding generation.

  3. A kNN self-query using Document A's own stored vector does not return Document A as the top (or any) result. Instead it returns the same fixed set of 5 unrelated documents that also appear as top results for two other, semantically unrelated query vectors — indicating multiple documents share this same incorrect vector.

  4. Reindex log for the run in question contains the following warning for a different entity type (queryCostRecord), evidencing an async callback correlation defect in the same PartitionWorker/bulk sink layer:

    WARN [...] PartitionWorker - Pending sink ops stuck at 13 for entity queryCostRecord after 3 retries with no progress. Reconciling early (callbacks likely lost). WARN [...] PartitionWorker - Reconciling 13 pending sink operations after 3 retries for entity queryCostRecord (bulk processor was flushed, treating as successful)

    This confirms the reindex pipeline has a known mechanism by which async operation results can lose correlation with their originating document, and that this is silently reconciled as success rather than surfaced as a failure or warning against the affected document.


Suspected root cause

Vector embedding generation is dispatched as an async HTTP call per document/batch to the configured OpenAI-compatible endpoint under BulkExecutor's default 10-thread concurrency. The callback correlation mechanism between "embedding response received" and "attach to source document" appears susceptible to a race condition under this concurrency level, particularly when the embedding provider introduces network-level latency (as with an external/sidecar HTTP provider, versus DJL's synchronous in-process inference). This has not been confirmed with DJL as the provider, since DJL is non-functional in this environment; it is unconfirmed whether this defect is provider-independent or specific to network-based embedding providers.

To Reproduce

  1. Configure OpenMetadata with an OpenAI-compatible embedding provider (custom endpoint, not Bedrock/OpenAI direct) and enable vector/semantic search.
  2. Run a full reindex covering >5,000 table entities.
  3. After completion, sample multiple document pairs via: GET /table_search_index/_doc/?_source=embedding,fingerprint,textToEmbed
  4. Compare embedding arrays across sampled pairs for exact equality.
  5. For any pair found identical, independently POST each document's textToEmbed string to the configured embedding endpoint and confirm the standalone responses differ from each other (ruling out embedding-service-side staticness).
  6. Confirm via kNN self-query (search using a document's own stored vector) that the source document does not rank as its own top match.

Expected behavior

Impact

Semantic/hybrid search silently returns incorrect and non-discriminating results for affected documents — multiple unrelated entities receive identical similarity scores against any query, making semantic search non-functional for the affected subset without any visible error, failed count, or health-check signal. Standard health checks (embedding configuration validation, reindex completion status) report success throughout.


Requested

  1. Confirm whether this is a known issue related to #26574 or a distinct defect in the bulk sink / vector embedding handler's async callback correlation logic.
  2. Confirm whether BulkExecutor thread count / queue size for reindex is intended to be configurable (env var or Helm value) — it is not currently exposed in the shipped openmetadata Helm chart (checked v1.13.1 chart and release values).
  3. Confirm whether this defect is reproducible with DJL as the embedding provider, or is specific to external/HTTP-based embedding providers under concurrent load.

OS

Red Hat build, Go 1.22.12, RHEL 9-based, OpenShift

Python version

3

OpenMetadata version

1.13.1

OpenMetadata Ingestion package version

1.13.1

Additional context

Environment note: This environment uses a custom OpenAI-compatible embedding sidecar (FastAPI + sentence-transformers) in place of DJL, due to DJL's incompatibility with Alpine/musl base images. Embedding calls are therefore network round-trips rather than synchronous in-process calls. It is unconfirmed whether this increases exposure to the BulkExecutor callback-loss race described above, or whether the defect is provider-independent. Reporter was unable to verify via request-level timing due to insufficient log retention on the embedding sidecar.

Pre-submission checklist

  • [x] I searched for duplicate issues.
  • [x] I removed credentials, hostnames, emails, and other sensitive data from logs and config.

AuTyi avatar Jul 02 '26 12:07 AuTyi

Thanks for the detail in this report — the direct document comparisons and the kNN self-query gave us a lot to work with.

We dug into this against your exact version (the 1.13.1 release), including building it and running a concurrency stress test through the reindex embedding path: 500 distinct entities at a time, 10 worker threads, randomized latency on every embedding call to imitate an external sidecar over the network, repeated 20 times. About 10,000 embedding calls, each one checked against the text that document actually submitted. We couldn't get a single vector to land on the wrong document.

That's consistent with how the path is built — each document's embedding is requested and attached as a single piece of work, so a response is never parked anywhere to be matched back to a document later. The warning you spotted about pending sink operations is real, but it comes from the bookkeeping that tracks how many writes have been acknowledged — it affects counters, not document content. Worth flagging too: the BulkExecutor threads=10, queue=1000 line is from a different subsystem (bulk entity API operations), not the reindex. Reindex concurrency is controlled by the search indexing app's own settings, and embedding calls are separately capped at 10 concurrent by maxConcurrentRequests.

On your other questions: #26574 was already in your build (it merged well before 1.13.1) and it only throttles concurrency, so it's unrelated to this. And the pipeline is provider-independent — DJL and HTTP providers run through the same code, differing only in transport.

That said, we found two things that could explain part of what you're seeing, and both are quick to check.

1. Did this index ever hold DJL-generated vectors? You mentioned switching to your sidecar because DJL doesn't work on Alpine/musl. DJL's default model is 384-dimensional — and so is yours. That combination slips past both of our safeguards: we only re-embed when an entity's content changes or when the vector length doesn't match, and a model swap at the same dimension changes neither. So if this index ever held DJL vectors, they'd still be sitting there being treated as current. An index mixing two models' vectors would give exactly the incoherent nearest-neighbour results you're describing. Relatedly — was your reindex a full recreate, or run in place over the existing index?

2. Is embedding actually indexed as a vector field? Could you share the output of GET table_search_index/_mapping and the index settings? We skip the kNN setup entirely if the embedding provider isn't reachable when the index is created. If that happened, embedding gets stored as an ordinary array of numbers and kNN queries against it aren't really doing vector search — which would explain your third observation (the same handful of documents coming back for unrelated query vectors) on its own.

One more thing that would help: your check that the service returns different vectors for each document's text was done one request at a time. Since the problem you're describing only shows up under concurrency, could you fire ~20 simultaneous requests with distinct texts at the sidecar and see whether any two responses come back identical? No reindex needed, and it would tell us whether to keep looking at the pipeline or at the provider.

We haven't explained the identical stored vectors yet, so we're not dismissing this — those answers would tell us where to dig next.

fmcardoso avatar Sep 03 '26 08:09 fmcardoso