Repository navigation
Fixes #35879: Keep search in sync after PUTs, renames, label changes and direct writes - #35888
Conversation
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.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
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.
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. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
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); |
There was a problem hiding this comment.
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.
…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)
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 sendtagsonly 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.updateTagsmerged the stored tags into a new list when the request had none, sopostUpdateindexed the entity without them. It now returns the merged list, and every caller assigns it back.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:
PIIandPIIExtra. Both passes are gone. Classifications, glossaries and glossary terms already rewrote their assets inline with the boundary-safe script, and tags now do too.tagsonly holds them merged.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:
ownerswith theownerDisplayNamelist,reviewers,experts,domains,dataProducts, a user'steamsand a team'sparents. It runs across the global alias and the user and team indexes, which sit outside it.domainfield its children do not have. The script failed, and took down the owners propagated to data products in the same update.PUTandDELETE /teams/{id}/usersmade no search write, so the users'teamsand the team's user count went stale.4. Writes outside the update path.
votesandtotalVotesare rewritten.deleteStaleskipped 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:
High-level design:
updateEntitiesByReference, deferred until the rename commits. They don't use another prefix script over raw FQNs.updateReferenceCopiesclient call that matches the nestedownerspath and the object reference paths by id. It is shaped like the existingupdateChildrenByNestedField.forEachNestedTagList, shared by the rename, delete and label scripts.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.userCountfrom reindexes too, because the team's reindex fields include it.EntityManagementClientgainsupdateReferenceCopieswith a default implementation. The Elasticsearch and OpenSearch clients implement it, and Collate's clients extend those.updateTagschanges fromvoidtoList<TagLabel>.openmetadata-collatemain neither overrides nor calls it.updateTeamUsersanddeleteTeamUser, 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
owners,ownerDisplayName,reviewersandexperts.ownersand a member'steams, and a parent team's reaches the child team'sparents.domains, and a data product's reach a table'sdataProducts.PUTandDELETE /teams/{id}/usersupdate the user'steamsand the team's user count, and a user's team change keeps the team document's owners.totalVotes.deleteStalesoft and hard deletes reach search.Unit tests
SearchRepositoryBehaviorTestcases. 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.Backend integration tests
openmetadata-integration-tests/.PutKeepsTagsInSearchIT(8): all 8 fail onmain, 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) andTeamMembershipSearchIT(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.it/util/SearchDocspolls the raw search document until a marker of the write under test appears, then the test asserts on it.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,BulkOverrideMetadataITandBulkSourceHashFastPathIT. 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 one6d686c2cb(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
Playwright (UI) tests
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:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with a non-blocking search inconsistency for deleted tags after a classification rename.Findings
Summary
Keeps stored tags in search when a PUT omits them and expands search refreshes for related writes.
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]Reviews (2) · Last reviewed commit: "Keep search documents complete on writes..." · Reviewed by Greptile