Skip to content

Fixes 35914: Prevent closed readers in OpenSearch embedding updates - #35917

Merged
mohityadav766 merged 1 commit into
mainfrom
agent/responseexception-events-tot
Oct 22, 2026
Merged

mohityadav766 merged 1 commit into
mainfrom
agent/responseexception-events-tot

Conversation

@harshach

@harshach harshach commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #35914

OpenSearch embedding updates can return HTTP 500 with already_closed_exception after concurrent updates, merges and scroll cleanup close a derived-source vector reader.

Commit 111eee439a3 loads shared OpenSearch vector settings from the spec mappings for entity and chunk indexes, including staged chunks. It sets index.knn.derived_source.enabled=false while preserving embedding indexing and kNN search. The regression test reproduces the failure on OpenSearch 3.4.0 and verifies updated vectors and existing document fields remain readable.

Type of change:

  • Bug fix

High-level design:

OsUtils and the chunk mapping builder share openmetadata-spec/src/main/resources/elasticsearch/opensearch_vector_index_mapping.json. The resource keeps vectors in stored _source, avoiding the failing derived-source reader path. Only OpenSearch consumes it; the supported OpenSearch baseline is 3.x onwards.

Existing indexes need a full reindex to recreate them with this static setting. Keeping vectors in _source increases disk usage; the increase has not been measured. See the decision record.

Tests:

Use cases covered

  • Entity and chunk embedding updates survive concurrent updates/refreshes, force merges and scroll cleanup.
  • Partial updates preserve the document name, update the fingerprint and retain the complete updated vector in _source.
  • A real kNN query still returns results, and the created indexes explicitly disable derived source.

Unit tests

  • Updated openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OsUtilsTest.java.
  • Current-commit affected unit run: 415 tests passed across 16 classes; individual classes and counts are in the Java results comment.
  • Focused final-mapping run: 189 unit tests passed across OsUtilsTest (38), EsUtilsTest (31), OpenSearchIndexManagerTest (62), IndexTemplateManagerTest (11), ImmenseTermReproTest (3), OpenSearchVectorMemoryAccessTest (1), OpenSearchVectorServiceChunkStagingTest (10), and OpenSearchVectorServiceTest (33).
  • Coverage: a fresh report is pending. The saved JaCoCo execution data did not match the current compiled classes, so its percentages are not reported.

Backend integration tests

Added openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OpenSearchVectorReaderIT.java, using a real OpenSearch 3.4.0 container and production index creation paths. Both parameterized cases failed with the reported HTTP 500 before the fix and passed after the final mapping change. The test writes fixed vectors and needs no external embedding provider.

The current-commit affected run is still running; its unit step passed all 415 tests. The broader run and fresh coverage collection remain pending. The last completed affected-run report below is from the earlier uncommitted implementation:

Local Java test run: FAILED

  • Commit: 0476bb31d51a (base HEAD) — uncommitted changes were present
  • Finished: 2026-10-22 01:08 UTC · 18.8 min
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-mcp (3 classes), openmetadata-service (13 classes) 16 415 0 0 3.6 passed
integration mysql-elasticsearch · parallel 1 2 0 0 5.6 passed
integration postgres-opensearch · parallel 37 1636 1 122 9.6 FAILED
integration postgres-opensearch · isolated not run
integration postgres-opensearch · rdf not run
integration postgres-opensearch · search-it not run

Failed: SearchRankingRelevanceIT#singularQueryFindsThePluralTable(TestNamespace)

  • Impacted, not run locally: 14 classes (listed in the details)

Additional focused verification of the final mapping implementation: 2 integration cases passed, alongside the 189 unit tests above:

mvn -B -ntp verify -pl openmetadata-integration-tests -am \
  -Ppostgres-opensearch -DintegrationTests.lane=parallel \
  -Dit.test=OpenSearchVectorReaderIT -Dfailsafe.failIfNoSpecifiedTests=false \
  -Dtest=OsUtilsTest,EsUtilsTest,OpenSearchVectorServiceTest,OpenSearchVectorServiceChunkStagingTest,OpenSearchVectorMemoryAccessTest,OpenSearchIndexManagerTest,IndexTemplateManagerTest,ImmenseTermReproTest \
  -Dsurefire.failIfNoSpecifiedTests=false -Dskip.embedded.bootstrap=true \
  -Dspring-boot.repackage.skip=true

Earlier implementation-stage runs:

  • The first post-fix run passed 158 unit tests and both regression cases; its subsequent SonarCloud upload failed because the project was unauthorized. Later verification without that upload succeeded.
  • The earlier affected run passed 415 unit tests and both regression cases under the MySQL/Elasticsearch application profile. Its PostgreSQL/OpenSearch parallel step ran 1,636 tests: 1,513 passed, 1 failed, 122 skipped.
  • That failure was SearchRankingRelevanceIT#singularQueryFindsThePluralTable. Embeddings were disabled on its table index and the new setting was absent. A clean-main baseline was not run, so this is not claimed to be a proven pre-existing failure. Later lanes were not run after that failure.

Ingestion integration tests

Not applicable — no ingestion changes.

Playwright (UI) tests

Not applicable — no UI changes.

Manual testing performed

  1. Started a local OpenSearch 3.4.0 container and created vector indexes with 1,000 documents.
  2. Ran concurrent partial updates/refreshes/flushes, force merges and scroll cleanup; reproduced already_closed_exception with derived source enabled.
  3. Recreated the indexes with derived source disabled and repeated the workload; updates and source reads succeeded while kNN search remained available.
  4. Verified the new mapping resource is packaged in the spec JAR.
  5. Ran Spotless apply/check for service and integration tests, git diff --check, the Java impact-map ownership check and the decision-record check; all passed.

UI screen recording:

Not applicable — backend search fix with no UI changes.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>.
  • My PR is linked to a GitHub issue via Fixes #35914 above.
  • I have commented on the non-obvious upstream workaround.
  • JSON Schema migrations: not applicable — this changes an index mapping resource, not a JSON Schema. Existing indexes require the full reindex described above.
  • UI feature recording: not applicable — no UI changes.
  • I have added unit/integration tests and listed them above.
  • Self-review: the final diff at 111eee439a3d64dcc5be82deff51857aed771a48 was reviewed against REVIEW.md.
    • The review's OpenSearch 2.x compatibility concern was withdrawn after the maintainer confirmed that only 3.x onwards is supported. No blocking findings remain.
  • Decision check: added docs/decisions/2026-10-21-opensearch-vectors-stay-in-source.md.
  • I have added a test covering the reported failure and observed it fail before the fix.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

OpenSearch entity and chunk indexes now share settings that keep vectors in stored _source while leaving kNN enabled.

  • OpenSearch vector indexes keep embeddings in _source and k-NN enabled.

No actionable issues were found. Tests were reviewed but not run during this review.

Acknowledged limitations:

  • harshach states that existing indexes need a full reindex that recreates them because the setting is static.
  • harshach acknowledges increased disk usage; the increase has not been measured.
  • harshach reports that the OpenSearch 2.x concern was withdrawn after the maintainer confirmed support starts at 3.x.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Resource["Shared OpenSearch vector settings"] --> Entity["OsUtils: entity index settings"]
  Resource --> Chunk["OpenSearchVectorService: chunk mapping"]
  Chunk --> Live["Live chunk index"]
  Chunk --> Staged["Staged chunk generation"]
  Entity --> Stored["Vectors remain in stored _source; kNN stays enabled"]
  Live --> Stored
  Staged --> Stored
Loading

Reviews (1) · Last reviewed commit: "Fixes #35914: Keep OpenSearch vectors in..." · Reviewed by Greptile

Load shared OpenSearch vector settings from the spec mappings for entity and chunk indexes, including staged chunks. Disable derived vector source while preserving embedding indexing and kNN search.

Reproduce the reader lifecycle failure on OpenSearch 3.4 with concurrent updates, merges and scroll cleanup. Verify partial updates preserve source fields and vector searches still work.

Document the disk storage tradeoff and full reindex required for existing indexes.
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 22, 2026
@harshach
harshach marked this pull request as ready for review October 22, 2026 01:51
@harshach
harshach requested a review from a team as a code owner October 22, 2026 01:51
@harshach
harshach requested a review from pmbrull October 22, 2026 01:51
@gitar-bot

gitar-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Disabling OpenSearch derived vectors stores embeddings in _source, increasing disk use and requiring full reindexing for existing indexes.

Keeps OpenSearch vector fields in stored _source by setting index.knn.derived_source.enabled=false in the shared vector mapping resource, preventing already_closed_exception during concurrent embedding updates while preserving kNN search. No issues found.

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

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

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.

Copy link
Copy Markdown
Collaborator Author

Earlier implementation-stage affected-test results, referenced in the PR description. This report predates commit 111eee439a3; it is retained to document the ranking failure and the tests already run. The new run on 111eee439a3 has passed all 415 selected unit tests and is still running integration tests.

Local Java test run: FAILED — details

  • Commit: 0476bb31d51a (base HEAD) — uncommitted changes were present
  • The summary is in the PR description.

Failed: SearchRankingRelevanceIT#singularQueryFindsThePluralTable(TestNamespace)

Tests run locally

  • unit · openmetadata-mcp (3 classes), openmetadata-service (13 classes): AvailableEntityTypesConsistencyTest (2 passed), CompanyContextToolTest (17 passed), DistributedJobParticipantTest (18 passed), GetEntityToolTest (32 passed), HighlightFieldClassifierTest (9 passed), ImmenseTermReproTest (3 passed), IndexTemplateManagerTest (11 passed), OSLineageGraphBuilderTest (15 passed), OpenSearchBulkSinkBehaviorTest (19 passed), OpenSearchVectorMemoryAccessTest (1 passed), OpenSearchVectorServiceChunkStagingTest (10 passed), OpenSearchVectorServiceTest (33 passed), OsUtilsTest (38 passed), SearchRepositoryBehaviorTest (152 passed), SemanticSearchToolTest (36 passed), VectorDocBuilderChunkTest (19 passed)
  • integration · mysql-elasticsearch · parallel: OpenSearchVectorReaderIT (2 passed)
  • integration · postgres-opensearch · parallel: 37 classes, 1514 tests executed (listed below)

Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts.

integration · postgres-opensearch · parallel: 42 classes

AccentInsensitiveSearchIT (7 passed), AliasSwapConcreteRemovalIT (3 passed, 1 skipped), AssetsTabSearchEntriesIT (112 passed, 6 skipped), AsyncSearchIndexConsistencyIT (6 passed), BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (19 passed, 4 skipped), CachedSearchLayerIT (5 passed), ColumnSearchIndexIT (0 passed), ColumnSearchIndexIT$ColumnDataTypeTests (10 passed), ColumnSearchIndexIT$ColumnInDataAssetTests (6 passed, 2 skipped), ColumnSearchIndexIT$ColumnSearchTests (8 passed, 1 skipped), ColumnSearchIndexIT$NestedColumnTests (0 passed), ConfigResourceIT (9 passed, 1 skipped), ContextMemorySearchMatrixIT (49 passed, 7 skipped), DataInsightAggregationIT (54 passed, 7 skipped), DataInsightAliasReconciliationIT (1 passed), DatabaseSmokeIT (1 passed), EntityNameIndexIT (1 passed), FlattenedChildrenHighlightSearchIT (1 passed), GlossaryTermResourceIT (206 passed, 6 skipped), IndexTemplateIT (0 passed), IndexingLimitsIT (2 passed), McpSearchIT (40 passed, 5 skipped), MlModelServiceSearchAliasIT (5 passed), OpenSearchVectorReaderIT (2 passed), OpensearchHC5ReactorReproIT (8 passed), OrphanedIndexCleanerScopedCleanupIT (3 passed), SearchClusterFitnessResourceIT (4 passed, 2 skipped), SearchConfigurationIT (22 passed, 1 failed, 2 skipped), SearchConsumerFieldBehaviorIT (125 passed, 7 skipped), SearchFieldlessQueryIT (3 passed), SearchIndexFieldLimitIT (360 passed, 27 skipped), SearchIndexImmenseTermIT (4 passed), SearchIndexPromotionIT (1 passed), SearchIndexResourceIT (21 passed), SearchIndexingFieldsParityIT (1 passed), SearchRankingRelevanceIT (0 passed), SearchResourceIT (33 passed, 5 skipped), SearchServiceResourceIT (0 passed), SeedDataPresenceIT (2 passed), TableResourceIT (10 passed), TestCaseSoftDeleteSearchIT (1 passed), UserResourceIT (106 passed, 5 skipped)

Why these tests
  • area search ← openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OsUtils.java, openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java
  • changed test ← openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OpenSearchVectorReaderIT.java, openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OsUtilsTest.java
  • smoke ← code other than a test class changed
Impacted, not run locally (14)
  • LineagePayloadScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • LineageScenePerformanceScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • OntologyScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ReindexBenchmarkIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ReindexCpuHeadroomIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • Scale100kEntitiesIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ServiceDeleteSearchCleanupScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • LongCompoundNameSearchUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • PipelineOwnerIndexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • DistributedAutoTuneReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableAllKindsDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SelectiveFieldReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SimpleReindexTriggerUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
Commands
mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AvailableEntityTypesConsistencyTest,CompanyContextToolTest,DistributedJobParticipantTest,GetEntityToolTest,HighlightFieldClassifierTest,ImmenseTermReproTest,IndexTemplateManagerTest,OSLineageGraphBuilderTest,OpenSearchBulkSinkBehaviorTest,OpenSearchVectorMemoryAccessTest,OpenSearchVectorServiceChunkStagingTest,OpenSearchVectorServiceTest,OsUtilsTest,SearchRepositoryBehaviorTest,SemanticSearchToolTest,VectorDocBuilderChunkTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=OpenSearchVectorReaderIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=parallel '-Dit.test=<37 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=global-state -Dit.test=PatchTableEmbeddingIT,SearchIndexRetryQueueIT,TestSuiteReindexIT,VectorEmbeddingIntegrationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=rdf -Dit.test=RdfIndexAppScaleIT,RdfIndexRunRecoveryIT,RdfReindexFailuresIT,RdfReindexInsertOnlyIT,RdfReindexRunLockIT,RdfSemanticSearchIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Psearch-it -DdatabaseType=postgres -DsearchType=opensearch -Djpw.data.mode=ingest -Dit.test=ColumnIndexingToggleIT,CustomPropertyAggregationIT,DbToEsCountReconciliationIT,ExtensionHighlightSearchIT,FieldNamesAggregationIT,HighlightFieldSaveValidationIT,IndexFieldExplosionIT,IndexMappingTemplatesIT,LiveIndexRetryIT,LiveSearchSettingsChangeIT,NestedHierarchyIndexIT,NoDuplicatesDuringReindexIT,OwnersNestedMappingIT,PerEntitySearchDefaultsIT,ReindexAliasSwapIT,ReindexDocSurvivalIT,ReindexOutageRecoveryIT,ReindexStatsIT,ReindexStopUnderLoadIT,SearchAggregateRbacIT,SearchClusterFitnessReindexE2EIT,SearchCountConsistencyIT,SearchEntityRankingIT,SearchRelevancyPreviewIT,SearchScoringIT,StagedIndexUnrefreshedCountIT,TestCaseStaleDefinitionReindexIT,UnsafeReindexConfigIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

@sonarqubecloud

Copy link
Copy Markdown

@harshach harshach added the To release Will cherry-pick this PR into the release branch label Oct 22, 2026
@mohityadav766
mohityadav766 added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 1cfeb2b Oct 22, 2026
198 of 201 checks passed
@mohityadav766
mohityadav766 deleted the agent/responseexception-events-tot branch October 22, 2026 09:39
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 opened as #35945 (clean cherry-pick). It merges itself once the checks pass.

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

Labels

backend safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenSearch embedding updates fail with already_closed_exception

2 participants