Skip to content

[2.1] Fixes 38939: Resolve stored parent references on read for every entity - #39624

Merged
sonika-shah merged 1 commit into
2.1from
backport/2.1/pr-38950
Dec 3, 2026
Merged

sonika-shah merged 1 commit into
2.1from
backport/2.1/pr-38950

Conversation

@gh-bot-collate

@gh-bot-collate gh-bot-collate Bot commented Dec 3, 2026

Copy link
Copy Markdown

Automated backport of #38950 to 2.1.

Source PR #38950
Author @dk-teknologisk-rfma
Merge commit c76ee35f1d61334dc75c4f0433449e16cd007672
Method Clean cherry-pick — identical to the commit on main.

Opened from openmetadata-collate, which holds the credentials needed to open a PR here. It merges itself once this branch's required checks pass — no review needed. If a check fails it stays open and the author of #38950 is asked to look.

resolver run

#38950)

* Fixes 38939: Resolve stored parent references on read for tables and schemas

Tables keep databaseSchema and database refs, and schemas keep their
database ref, in their stored JSON. Reads trusted those copies whenever
they had an id, so after a parent's displayName changed, GET, list and a
full search reindex (which reads through setFieldsInBulk) kept returning
the old name. Re-read the refs by id on read: a cached lookup on the
single-entity path, one batched reference query per page on the bulk path.

Fixes #38939

* Keep a stored parent reference when the parent is gone

currentReference threw EntityNotFoundException for a missing parent,
so a table or schema whose parent row was gone could no longer be read.
Fall back to the stored copy, as the bulk path already does, and record
the read-time resolution rule as a decision.

* Refresh every stored parent reference on read

Tables and schemas were not the only entities returning a renamed parent's
old displayName. File (directory, service on list and reindex), Query
(service), DataContract (entity, testSuite), ontology definitions and
OntologyChangeSet (ontology) and AIFrameworkControl (framework) all keep a
copy of their parent reference in stored JSON and returned it as stored.

Each repository now declares those references in
getStoredParentReferences(). EntityRepository refreshes them after setFields
on the single-entity path (entity cache) and at the start of the default
setFieldsInBulk (one reference-only query per parent type per page). Table
and DatabaseSchema move onto the same declaration. refreshStoredReferences
groups ids by the type each reference names, so a field that points at
several entity types costs one query per type.

StoredParentReferenceIT renames each parent and checks GET and list for
every declared entity; it fails on the code before this PR.

* Leave the test suite rename out of the shared-server data contract test

Renaming a contract's test suite writes a string into the embedded
testSuites change description of its test cases, which the shared data
insights index maps as boolean (#38799), so DataInsightAiAssetCoverageIT
rejected the record. The test keeps checking the contract's entity.

* Compare a data contract's test suite by identity

Reads now return the suite's current reference, while prepare() rebuilds
updated.testSuite from its id, FQN and type, so the full-object comparison
recorded a testSuite change on an unchanged PUT and bumped the version.
Compare it with entityReferenceMatch, as qualityExpectations already is.

StoredParentReferenceIT gains a no-op PUT test (0.1 -> 0.2 before this
change) and now cleans up its drive and database services, ontologies and
AI framework fixtures.

* Read large parents by reference row and drop redundant list queries

- A data contract's entity (usually a table) is read with the reference-only
  query on the single-entity path: rebuilding the reference from the entity
  cache deserialized the whole table JSON on every GET.
- A contract's testSuite is no longer declared: the contract owns its suite.
  This also restores the plain testSuite comparison in the updater.
- The schema list no longer runs a second database query: every stored row
  already goes through batchFetchDatabases.
- The table list takes databaseSchema from the schemas fetchAndSetDefaultFields
  already loaded, so only the database reference needs a query.
- StoredParentReferenceCoverageTest fails when a repository with stored parent
  references overrides setFieldsInBulk without being listed with its test.
- The decision record lists the covered entities and the stored references not
  declared yet.

* Require every stored reference to be declared or listed with a reason

- StoredReferenceDeclarationTest finds, for every repository, the single
  EntityReference fields its entity keeps in stored JSON and fails unless each
  is declared in getStoredParentReferences() or listed with its reason. The
  64 listed today are grouped: re-read by their own repository, actors,
  configuration links, deprecated single domains, owned or point-in-time
  references, and two parents not declared yet.
- A stored reference whose type has no repository keeps its stored copy
  instead of failing the read.
- StoredParentReferenceIT covers the reindexed search doc of a table under
  renamed parents, an unchanged update after a parent rename and a
  soft-deleted parent; the no-op contract PUT test no longer guarded this
  change and is dropped.
- The decision record lists the side effects: deleted on references under a
  soft-deleted parent, refreshed labels in version history, orphan lookups,
  and the reads that still return the stored copy.

---------

Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: Ram Narayan Balaji <[email protected]>
(cherry picked from commit c76ee35)
@gh-bot-collate
gh-bot-collate Bot requested a review from a team as a code owner December 3, 2026 06:36
@gh-bot-collate
gh-bot-collate Bot requested review from manerow and removed request for a team December 3, 2026 06:36
@gh-bot-collate gh-bot-collate Bot added the safe to test Add this label to run secure Github workflows on PRs label Dec 3, 2026
@gh-bot-collate

gh-bot-collate Bot commented Dec 3, 2026

Copy link
Copy Markdown
Author

🤖 This backport will not merge itself: 2.1 has no required status checks, so there is nothing for auto-merge to wait on. Merge it by hand once CI is green.

@sonika-shah
sonika-shah merged commit 3cbd9b0 into 2.1 Dec 3, 2026
42 of 45 checks passed
@sonika-shah
sonika-shah deleted the backport/2.1/pr-38950 branch December 3, 2026 12:05
pmbrull added a commit that referenced this pull request Dec 3, 2026
…ompile (#39703)

#39624 backported StoredParentReferenceIT, which calls
SearchDocs.awaitDocAsserted. That helper came in on main with #36256 and
was never backported, so openmetadata-integration-tests fails to
test-compile on 2.1. Bring over just the helper.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants