Skip to content

Fixes #35879: Keep search in sync after PUTs, renames, label changes and direct writes - #35888

Merged
mohityadav766 merged 5 commits into
mainfrom
fix/put-keeps-tags-in-search
Oct 26, 2026
Merged

mohityadav766 merged 5 commits into
mainfrom
fix/put-keeps-tags-in-search

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #35879

This started as #35879: a PUT that omits tags keeps the stored tags in the database, but the search document it writes loses them. Auditing the other write paths for the same kind of gap turned up more places where a change reaches the database and only part of it, or none of it, reaches search. This PR fixes those too. There is one commit per area.

1. A PUT keeps the entity's tags in search (#35879). Since #28155, connectors send every entity as a PUT, mostly through /bulk, and they send tags only when the source has some. So every ingestion run that changes an entity dropped the tags users applied in OpenMetadata, Tier included, from its search document. There were two causes:

  • EntityUpdater.updateTags merged the stored tags into a new list when the request had none, so postUpdate indexed the entity without them. It now returns the merged list, and every caller assigns it back.
  • The bulk path never loaded the stored field tags of topics, API endpoints and search indexes, so there was nothing to merge. Their PUT fields now include those fields, as tables already list columns.

2. Renames and moves. A rename or move rewrites the descendants' FQNs in the database without running their updaters, and the asset-side rewrite missed or damaged some copies:

  • Renaming or moving a glossary term or tag, or renaming a classification, now re-indexes the descendant terms and tags, by the ids captured before the rewrite. Their documents kept the old FQN, so search results for them pointed at entities that no longer resolve.
  • Moving a tag to another parent now rewrites the tag on tagged assets, as a rename already did.
  • The post-commit rename pass substring-replaced the FQN of every tagged asset, so a table whose FQN contained the tag's FQN was renamed along with the tag. The classification rename did the same to sibling classifications that share a name prefix, such as PII and PIIExtra. Both passes are gone. Classifications, glossaries and glossary terms already rewrote their assets inline with the boundary-safe script, and tags now do too.
  • Tag and glossary term renames and deletes now also reach the labels nested in columns, data model columns, schema fields, search index fields, ML features and pipeline tasks. Top-level tags only holds them merged.
  • A tag's or glossary term's display name or style change now reaches the label copies on assets, nested ones included. Clearing a value removes it.

3. Label copies and team membership. Documents copy the name and display name of the users, teams, domains and data products they reference, and nothing rewrote those copies:

  • A user's or team's display-name change, or a domain's or data product's rename or display-name change, now relabels every copy by id. That covers owners with the ownerDisplayName list, reviewers, experts, domains, dataProducts, a user's teams and a team's parents. It runs across the global alias and the user and team indexes, which sit outside it.
  • A domain's display-name change ran a child script that wrote a domain field its children do not have. The script failed, and took down the owners propagated to data products in the same update.
  • PUT and DELETE /teams/{id}/users made no search write, so the users' teams and the team's user count went stale.
  • A user's team change re-indexed each team from a read of only its id and user count, which blanked the owners and domains in the team's document.

4. Writes outside the update path.

  • A recursive soft delete or restore re-indexed the descendants from what the bulk updater had loaded. That left out what a PUT does not touch and what a descendant inherits, so a restored table lost its inherited owners and domains in search. The dispatched entities now load the search fields first.
  • A vote re-indexed the entity from a bare read, blanking owners, domains and tags. The vote change now travels with the entity, so only votes and totalVotes are rewritten.
  • Adding a dbt data model to a table wrote its tags, owners and column tags to the database only.
  • deleteStale skipped the post-delete steps, so a hard-deleted stale entity kept its search document. Soft deletes were already fine, because they run the updater.

Not in this PR: update-by-query cascades are still fire-and-forget (wait_for_completion=false, conflicts=proceed, the task result is discarded), and staged-index routing during a recreate reindex exists only on the pod that runs it. Both need design work, so they are follow-ups.

Type of change:

  • Bug fix

High-level design:

  • What gets stored is unchanged; only what gets indexed, and when, changes. No schema, REST or migration change.
  • Renames re-index descendants by id through updateEntitiesByReference, deferred until the rename commits. They don't use another prefix script over raw FQNs.
  • Label copies are rewritten by one async update-by-query per change: a new updateReferenceCopies client call that matches the nested owners path and the object reference paths by id. It is shaped like the existing updateChildrenByNestedField.
  • Nested tag lists are walked by one Painless fragment, forEachNestedTagList, shared by the rename, delete and label scripts.
  • A domain's own child propagation (to subdomains and data products) now runs through the synchronous, reconciled updateChildren. A domain has few children, and the relabel pass that follows rewrites the same data products. Two async passes over one document lose one of the writes to a version conflict, which the IT caught.
  • Team documents now carry userCount from reindexes too, because the team's reindex fields include it.
  • Compatibility:
    • EntityManagementClient gains updateReferenceCopies with a default implementation. The Elasticsearch and OpenSearch clients implement it, and Collate's clients extend those.
    • updateTags changes from void to List<TagLabel>. openmetadata-collate main neither overrides nor calls it.
    • Collate's SCIM group sync calls updateTeamUsers and deleteTeamUser, so SCIM membership changes now reach the users' documents too. They are re-indexed in batches of 100, after the relationship rows are written.

Tests:

Use cases covered

  • PUT: a connector re-run that adds a column and sends no tags keeps the table's tags, Tier and column tags in search. A bot bulk PUT keeps topic schema field, API endpoint field, ML feature and search index field tags, and a PUT without tags keeps a glossary term's tags.
  • Renames and moves:
    • Renaming or moving a glossary term re-indexes its descendant terms, and renaming a parent tag re-indexes its child tags.
    • Moving a tag rewrites the tag on the tagged assets.
    • A classification rename leaves sibling classifications that share its name prefix alone, and a tag rename leaves the tagged table's own FQN alone when that FQN contains the tag's.
    • Tag renames and deletes reach column tags, and a tag's display name and style reach the labels on the table and its columns.
  • Label copies:
    • A user's display name reaches owners, ownerDisplayName, reviewers and experts.
    • A team's display name reaches owners and a member's teams, and a parent team's reaches the child team's parents.
    • A domain's rename and display name reach a table's and a user's domains, and a data product's reach a table's dataProducts.
    • A domain's owners reach its data products, also when its display name changes in the same update.
  • Membership: PUT and DELETE /teams/{id}/users update the user's teams and the team's user count, and a user's team change keeps the team document's owners.
  • Direct writes:
    • A recursive soft delete and restore of a schema keep the tables' inherited domain and owners.
    • A vote keeps owners and tags and updates totalVotes.
    • A dbt data model reaches the table's tags and column tags.
    • deleteStale soft and hard deletes reach search.

Unit tests

  • Updated two SearchRepositoryBehaviorTest cases. The glossary term case now pins that no prefix rewrite runs after a rename, and that the display name reaches the label copies. The domain case pins the synchronous child update. The touched search unit tests pass: 413 tests.
  • Coverage %: not measured, because ITs aren't instrumented.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/.
  • Files added, each RED on the code before its commit and GREEN after (MySQL and Elasticsearch):
    • PutKeepsTagsInSearchIT (8): all 8 fail on main, and all 8 pass with the first commit. This was verified earlier, together with the full IT run 39591911599 on that commit.
    • RenameCascadeSearchIT (9): all 9 fail before the rename commit, 4 on assertions and 5 on timeouts. For example, the sibling classification's tag became …RenamedData.Sibling, and the table's own FQN became …OwnFqnx.schema…. All 9 pass after it.
    • ReferenceLabelSearchIT (6) and TeamMembershipSearchIT (2): every case fails at its post-change wait before the label commit, and all 8 pass after it.
    • DirectWritesSearchIT (5): the soft-delete/restore, vote, dbt data model and hard stale-delete cases fail before the last commit, and all 5 pass after it. The soft stale delete passed before too, because a soft delete already runs the updater.
  • The shared helper it/util/SearchDocs polls the raw search document until a marker of the write under test appears, then the test asserts on it.
  • On the final code, ran locally on the parallel lane: all five new ITs plus TagResourceIT, ClassificationResourceIT, GlossaryResourceIT, GlossaryTermResourceIT, GlossaryTagChildPropagationIT, GlossaryTagChildPersistenceIT, UserResourceIT, TeamResourceIT, DomainResourceIT, DataProductResourceIT, DatabaseSchemaResourceIT, DatabaseResourceIT, DatabaseServiceResourceIT, BulkDeleteStaleIT, TableResourceIT, TableColumnTagsIT, TableDataModelCertificationIT, AssetsTabSearchEntriesIT, BulkAssetChangeEventUserIT, DashboardResourceIT, DashboardServiceResourceIT, ChartResourceIT, ContainerResourceIT, StoredProcedureResourceIT, SearchResourceIT, BulkOverrideMetadataIT and BulkSourceHashFastPathIT. That was 4519 tests, 369 skipped, 0 failures, and no search-update errors in the server log.

The planner selects the full service unit suite and the full IT suite, because the change touches EntityRepository. The related ITs above passed locally. The full IT suite last ran on e6d686c2cb (https://github.com/open-metadata/OpenMetadata/actions/runs/39591911599, passed), before the rename, label and direct-write commits. It has not run on the current head.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

The #35879 reproduction is unchanged (see the issue). Before writing the tests, I reproduced the rename, move, label and soft-delete cases on a 2.0.5 stack with scripts against the API and the search index.

UI screen recording:

Not applicable: backend-only fix.

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 #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable, no schema change.
  • For a UI feature or feature task: not applicable.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with a non-blocking search inconsistency for deleted tags after a classification rename.

Findings

  1. P2 Deleted tags keep old names ▶

Summary

Keeps stored tags in search when a PUT omits them and expands search refreshes for related writes.

  • PUTs keep saved tags in the search documents they rewrite.
  • Direct writes and membership changes keep related search documents up to date.
  • Search copies of renamed tags and references show their current names.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[PUT omits tags] --> B[Load stored tags]
  B --> C[Merge stored and requested tags]
  C --> D[Assign returned list]
  D --> E[Write search document]
  E --> F[Tag and Tier filters retain matches]
Loading

Reviews (2) · Last reviewed commit: "Keep search documents complete on writes..." · Reviewed by Greptile

A PUT merges the stored tags into the request's. When the request carried
no tags, updateTags did that merge in a new list that the entity never saw.
The database kept the tags, but the entity that gets indexed had none. The
full-document search update then dropped them, and the Tier with them.

Since #28155, connectors send every entity as a PUT, mostly through
/bulk, and let the server skip the unchanged ones. Before, they PATCHed
the ones that changed. Connectors send tags only when the source has some.
So every ingestion run that changes an entity drops the tags users applied
in OpenMetadata from its search document, until the next reindex. Tags on
topic and API endpoint schema fields and on ML features are lost the same
way, because those lists default to null too.

updateTags now returns the tags the entity or field ends up with, and every
caller keeps that list.

Topics, API endpoints and search indexes also lost their field tags on the
bulk path for a second reason. A PUT loads the stored entity with its PUT
fields, and their bulk loaders read nested field tags only when the schema
or fields are requested. These repositories listed no PUT fields, so the
stored fields carried no tags to merge. They now list messageSchema,
requestSchema/responseSchema and fields, as tables already list columns.
@mohityadav766
mohityadav766 requested a review from a team as a code owner October 21, 2026 11:26
@mohityadav766
mohityadav766 requested a review from TeddyCr October 21, 2026 11:26
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 21, 2026
@mohityadav766 mohityadav766 self-assigned this Oct 21, 2026
@mohityadav766 mohityadav766 added the To release Will cherry-pick this PR into the release branch label Oct 21, 2026
@mohityadav766
mohityadav766 added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-21T22:47:25Z)

Blocked the queue: playwright-summary

Failed Playwright tests:

  • Features/TeamsHierarchy.spec.ts › Only Group teams are selectable in user profile teams edit

@mohityadav766
mohityadav766 added this pull request to the merge queue Oct 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-22T04:27:40Z)

Blocked the queue: playwright-summary

Failed Playwright tests:

  • Features/Table.spec.ts › expand / collapse should not appear after updating nested fields table

Renames and moves rewrote descendant FQNs in the database without re-indexing
the descendants, and the asset-side rewrite missed or damaged some copies:

- Renaming or moving a glossary term, tag or classification now re-indexes
  the descendant terms and tags (by the ids captured before the rewrite), so
  their documents no longer keep the old FQN (Kpler 21758).
- Moving a tag to another parent now rewrites the tag FQN on tagged assets,
  as a rename already did.
- The post-commit rename pass substring-replaced the FQN of every tagged
  asset (a table whose FQN contained the tag's FQN was renamed with it) and
  the classification rewrite did the same to sibling classifications sharing
  a name prefix. Both are gone: each repository rewrites its assets inline
  with the boundary-safe script.
- Tag renames and deletes also reach the tag labels nested in columns, data
  model columns, schema fields, search-index fields, ML features and tasks.
- A tag's or glossary term's display name or style change now reaches the
  label copies on assets, including nested ones, and clearing a value
  removes it.
… in search

Documents copy the name and display name of the users, teams, domains and
data products they reference, and nothing rewrote those copies:

- A user's or team's display-name change, or a domain's or data product's
  rename or display-name change, now relabels every copy by id: owners and
  the ownerDisplayName list, reviewers, experts, domains, dataProducts, a
  user's teams and a team's parents, across the global alias and the user and
  team indexes.
- A domain's display-name change ran a child script that wrote a "domain"
  field its children do not have. The script failed, and took down the owners
  propagated to data products in the same update. Domains and data products
  now leave their labels to the relabel pass, and a domain's own child
  propagation runs synchronously, so that it does not race the relabel pass
  over the same data products.
- Adding or removing members through /teams/{id}/users made no search write,
  so the users' teams and the team's user count went stale. Both documents
  are rebuilt now.
- A user's team change re-indexed each team from a read of only its id and
  user count, which blanked the owners and domains in the team's document.
  The teams are re-indexed from full reads, and the user count is part of a
  team document.
- A recursive soft delete or restore re-indexed the descendants from what
  the bulk updater had loaded. That leaves out what a PUT does not touch and
  what a descendant inherits, so a restored table lost its inherited owners
  and domains in search. The dispatched entities now load their search
  fields first.
- A vote re-indexed the entity from a bare read, blanking owners, domains
  and tags. The vote change now travels with the entity, so only the votes
  and their total are rewritten.
- Adding a dbt data model to a table wrote its tags, owners and column tags
  to the database only. The table is re-indexed afterwards.
- deleteStale skipped the post-delete steps, so a hard-deleted stale entity
  kept its search document.
@mohityadav766 mohityadav766 changed the title Fixes #35879: Keep entity tags in search after a PUT that omits them Fixes #35879: Keep search in sync after PUTs, renames, label changes and direct writes Oct 23, 2026
@gitar-bot

gitar-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Broad search-index cascades rewrite tags, labels, memberships, and lifecycle documents; matching or update errors could leave many entities’ search data incorrect.

Keeps search documents in sync with the database across PUTs, renames, moves, label changes, team membership, vote, soft delete/restore, dbt data model and stale-delete writes, so tags, owners and domains are no longer dropped from 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


invalidateClassification(updated.getId());
EntityRepository.finishInvalidateCacheForRenameCascade(Entity.TAG, renamedTags);
reindexRenamedDescendants(Entity.TAG, renamedTags, newFqn);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Deleted tags keep old names

After a classification rename, soft-deleted tags keep their old names in search. The removed prefix update included those documents, but its replacement calls updateEntitiesByReference, which reads only Include.NON_DELETED. The database still renames every descendant, including deleted ones.

Allow this rename refresh to load deleted descendants too. Otherwise, searches with deleted=true return names that no longer match the database.

@mohityadav766
mohityadav766 added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 361a62f Oct 26, 2026
86 of 87 checks passed
@mohityadav766
mohityadav766 deleted the fix/put-keeps-tags-in-search branch October 26, 2026 10:41
mohityadav766 added a commit that referenced this pull request Oct 26, 2026
…and direct writes (#35888) (#36255)

* Fixes #35879: Keep entity tags in search after a PUT that omits them

A PUT merges the stored tags into the request's. When the request carried
no tags, updateTags did that merge in a new list that the entity never saw.
The database kept the tags, but the entity that gets indexed had none. The
full-document search update then dropped them, and the Tier with them.

Since #28155, connectors send every entity as a PUT, mostly through
/bulk, and let the server skip the unchanged ones. Before, they PATCHed
the ones that changed. Connectors send tags only when the source has some.
So every ingestion run that changes an entity drops the tags users applied
in OpenMetadata from its search document, until the next reindex. Tags on
topic and API endpoint schema fields and on ML features are lost the same
way, because those lists default to null too.

updateTags now returns the tags the entity or field ends up with, and every
caller keeps that list.

Topics, API endpoints and search indexes also lost their field tags on the
bulk path for a second reason. A PUT loads the stored entity with its PUT
fields, and their bulk loaders read nested field tags only when the schema
or fields are requested. These repositories listed no PUT fields, so the
stored fields carried no tags to merge. They now list messageSchema,
requestSchema/responseSchema and fields, as tables already list columns.

* Keep renamed and moved tags and glossary terms in sync in search

Renames and moves rewrote descendant FQNs in the database without re-indexing
the descendants, and the asset-side rewrite missed or damaged some copies:

- Renaming or moving a glossary term, tag or classification now re-indexes
  the descendant terms and tags (by the ids captured before the rewrite), so
  their documents no longer keep the old FQN (Kpler 21758).
- Moving a tag to another parent now rewrites the tag FQN on tagged assets,
  as a rename already did.
- The post-commit rename pass substring-replaced the FQN of every tagged
  asset (a table whose FQN contained the tag's FQN was renamed with it) and
  the classification rewrite did the same to sibling classifications sharing
  a name prefix. Both are gone: each repository rewrites its assets inline
  with the boundary-safe script.
- Tag renames and deletes also reach the tag labels nested in columns, data
  model columns, schema fields, search-index fields, ML features and tasks.
- A tag's or glossary term's display name or style change now reaches the
  label copies on assets, including nested ones, and clearing a value
  removes it.

* Relabel the copies of renamed users, teams, domains and data products in search

Documents copy the name and display name of the users, teams, domains and
data products they reference, and nothing rewrote those copies:

- A user's or team's display-name change, or a domain's or data product's
  rename or display-name change, now relabels every copy by id: owners and
  the ownerDisplayName list, reviewers, experts, domains, dataProducts, a
  user's teams and a team's parents, across the global alias and the user and
  team indexes.
- A domain's display-name change ran a child script that wrote a "domain"
  field its children do not have. The script failed, and took down the owners
  propagated to data products in the same update. Domains and data products
  now leave their labels to the relabel pass, and a domain's own child
  propagation runs synchronously, so that it does not race the relabel pass
  over the same data products.
- Adding or removing members through /teams/{id}/users made no search write,
  so the users' teams and the team's user count went stale. Both documents
  are rebuilt now.
- A user's team change re-indexed each team from a read of only its id and
  user count, which blanked the owners and domains in the team's document.
  The teams are re-indexed from full reads, and the user count is part of a
  team document.

* Keep search documents complete on writes outside the update path

- A recursive soft delete or restore re-indexed the descendants from what
  the bulk updater had loaded. That leaves out what a PUT does not touch and
  what a descendant inherits, so a restored table lost its inherited owners
  and domains in search. The dispatched entities now load their search
  fields first.
- A vote re-indexed the entity from a bare read, blanking owners, domains
  and tags. The vote change now travels with the entity, so only the votes
  and their total are rewritten.
- Adding a dbt data model to a table wrote its tags, owners and column tags
  to the database only. The table is re-indexed afterwards.
- deleteStale skipped the post-delete steps, so a hard-deleted stale entity
  kept its search document.

(cherry picked from commit 361a62f)
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.

Tags and Tier disappear from search after an ingestion run that changes the table

2 participants