Skip to content

Reconcile live vector fields with the embedding model on both engines - #38845

Open
manerow wants to merge 5 commits into
mainfrom
fix/reconcile-live-vector-fields
Open

manerow wants to merge 5 commits into
mainfrom
fix/reconcile-live-vector-fields

Conversation

@manerow

@manerow manerow commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Follow-up to PR #38517.

The gap. On main, migrate and server start create indexes before any embedding client exists, so vector indexes get no embedding field (on OpenSearch no index.knn, which cannot be added later). After a model switch, vector writes fail one by one and vector search returns 500.

What changes.

  • The model is known before indexes exist. SearchRepository.getEmbeddingModel() reads it from the configuration, so migrate and startup create vector indexes with the pinned field, the model in _meta and, on OpenSearch, index.knn, without provider credentials. For DJL, migrate sets only index.knn and server start declares the field. A model is its exact configured id.
  • One rule (EmbeddingFieldUpdate), both engines: declare a missing field, keep one that holds the model, leave anything else. Another model of the same dimension is fully fixed only with PR #38882.
  • Server start applies it. Startup and migrate log one error naming each index and the way out, and never fail on it.
  • Reindex required (VectorFieldHealth): writes skip such indexes; vector search reads only the indexes that can hold the vectors and answers 503 when none can. The status page's Semantic Search step says so.
  • The post-upgrade reindex repairs them. The smart reindex (no --force) counts such an index as out of date (CANNOT_HOLD_VECTORS), so any upgrade rebuilds exactly those; the status page and command log name each index. The OpenSearch ontology chunk index is rebuilt with both term types and swapped in once both are promoted. No migration, no server-started rebuild.

Decision record: ADR:2026-11-26-the-server-reconciles-live-vector-fields-with-the-embedding-model; ADR:2026-11-23-elasticsearch-vector-fields-pin-their-index-options updated.

Release note. OpenSearch indexes created by a 2.1 migrate lack vector support; the standard post-upgrade reindex rebuilds them, and the status page names them meanwhile. Changing the configured embedding model id, even cosmetically (a Bedrock us. prefix), makes the next post-upgrade reindex re-embed the whole catalog, which costs provider calls.

Type of change:

  • Bug fix

Tests:

  • Unit: 1,092 tests in 42 affected classes; each new test fails with its fix reverted.
  • ITs: ElasticsearchVectorMappingUpdateIT (ES 9.3.0) 14/14, OpenSearchVectorMappingUpdateIT (OS 3.4.0) 16/16, VectorChunkIndexIT (both engines) 12/12.

Manual testing performed

E2E on OS 3.4.0, upgrade from main, 40 vector indexes without index.knn (table rebuilt):

Step main this PR
Smart reindex nothing rebuilt the 39 others rebuilt, the rest kept
Smart reindex again nothing to rebuild
Server start both status steps pass; vector search 200

Model switch (384 to 768) after an ontology release, then smart reindex:

previous head this PR
ontology_embeddings_chunks still 384 dimensions alias over a new 768 generation
Semantic Search step fails, names it passes
Ontology vector search 503 both terms found
Smart reindex again "No index mapping changes" nothing to rebuild

Checklist:

  • I have added a test that covers the exact scenario we are fixing.

@manerow
manerow requested a review from a team as a code owner November 26, 2026 11:43
@manerow
manerow requested a review from harshach November 26, 2026 11:43
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@manerow manerow added skip-pr-checks Bypass PR metadata validation check safe to test Add this label to run secure Github workflows on PRs labels Nov 26, 2026
@gitar-bot

gitar-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 2 closed / 2 findings

Changes vector-index rebuilds and alias promotion across both search engines; faulty coordination could leave semantic-search indexes incomplete or unavailable.

Reconciles live vector fields with the configured embedding model on both Elasticsearch and OpenSearch, so vector indexes are created with the pinned field and the post-upgrade reindex rebuilds those that cannot hold the vectors. Resolved the optional-field null sentinel issue and the smart reindex gap that never rebuilt a mismatched ontology chunk index. No open issues found.

✅ 2 closed
✅ Quality: Optional field with null as 'not resolved yet' sentinel

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:587-588 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:1062-1067
configuredEmbeddingModel is an Optional<EmbeddingModel> field, and null means "not resolved yet". The repository's Java rules forbid using Optional as a field or setting it to null. With three states packed into one field, any future reader that skips configuredEmbeddingModel() can get an NPE. It is also easy to mix up "unresolved" with "resolved to empty", for example an invalid config that is now cached for good. A fix is to keep a nullable EmbeddingModel plus a boolean configuredModelResolved, or a small holder record, and build the Optional only in the accessor.

✅ Bug: Smart reindex never rebuilds a mismatched ontology chunk index

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:1072-1086 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:1155-1164 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/VectorFieldHealth.java:31-34
checkVectorFields() checks every name in vectorIndexService.chunkIndexNames(). On OpenSearch that list includes OntologyChunkIndex.name() (AbstractVectorIndexService.java:190-195), so an ontology chunk index holding another model's vectors gets recorded in VectorFieldHealth. entityTypesThatCannotHoldVectors() only turns two kinds of mismatch into entity types: entity indexes, and the data-asset chunk index via getChunkIndexName(). The ontology chunk mismatch is dropped.

What goes wrong:

  • IndexMappingVersionTracker never reports CANNOT_HOLD_VECTORS for ontology types.
  • The smart reindex prints "Reindexing skipped - no changes detected".
  • The status page's reindex step passes while the Semantic Search step fails.
  • The index stays blocked, even though the new WAY_OUT text tells operators that openmetadata-ops.sh reindex "rebuilds exactly these".

The ontology chunk index is a plain index that ensureOntologyChunkIndex creates once, not a staged generation. Rebuilding the ontology entity types does not replace it either.

Fix: map this mismatch to a real rebuild. One option is to have the smart reindex drop and recreate the ontology chunk index, then add the ontology concept and property types. Otherwise, leave this index out of the "rebuilds exactly these" claim and give its own way out in the report.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants