fix(zdu): tolerate unknown entity types, aspects and references after a rollback

Merged
GD
24d ago
+14338-661

Summary

After a zero-downtime upgrade is rolled back from N to N-1, N-1 keeps running on data N wrote. Today one item N-1 doesn't know (an entity type, an aspect, a field or an enum value) can fail a whole batch, page, request or upgrade job.

With this PR, N-1 skips what it doesn't know, never stores or indexes it, and leaves N's data in place, so rolling forward to N restores everything. Nothing changes for data N-1 knows.

Flags (all off by default, so nothing changes until they are set):

Env varTurns on
UNKNOWN_DATA_TOLERANCE_ENABLEDBoth kinds below. This is the one to set for a rollback
UNKNOWN_ENTITY_ASPECT_TOLERANCE_ENABLED (featureFlags.unknownEntityAspectToleranceEnabled)Sections 1–3 and 5: unknown entity types, aspects, references, and malformed MCP urns
UNKNOWN_ENUM_TOLERANCE_ENABLED (featureFlags.unknownEnumToleranceEnabled)Section 4: unknown enum symbols and union members

To roll back N → N-1: set UNKNOWN_DATA_TOLERANCE_ENABLED=true in N-1's values (GMS, consumers and system update). Each kind's own env var overrides the umbrella either way. If N changed both kinds and only one is tolerated, N-1's system update fails on the other, as before; a row stamped with a newer schemaVersion is the exception, treated as N's under either kind. With both off, every path behaves as before this PR. With a flag on, data N-1 knows is still handled exactly as before.

What is handled

1. Unknown entity type (e.g. urn:li:zduWidget:*, added by N)

Tolerated only if N registered it, meaning its urn:li:entityType:datahub.<name> row exists. Any other unknown type, such as a typo, is rejected as before.

WhereBeforeAfter
Reads, search, relationships, GraphQL listsWhole page or list failed or was nulledOnly that item is left out
A known aspect referencing it (owner, data product asset, incident entity)Read, save or index of the aspect failedLeft out on read. A save keeps the stored reference unless the client cleared the field holding it; adding a new one is rejected (400)
Kafka MCP / MCL batchWhole batch failedMCP goes to the failure topic on its own; MCL is skipped
API request naming it500, or 200 doing nothing400
Ingestion rollback, RestoreIndices, deletes, consistency checksFailed, looped, or proposed deleting N's dataRows left in place and counted

2. Unknown aspect (e.g. zduDatasetMore on a dataset)

WhereBeforeAfter
Entity reads, RestoreIndices, LoadIndicesFailed on the rowRow skipped; stays in the database for N
Writes / deletes beside itCould failSucceed; N's row is kept
Kafka MCP / MCL batchWhole batch failedOnly that event is skipped / sent to the failure topic
API request naming it500400
Ingestion rollbackFailedLeaves it in place, reports aspectsLeftInPlace

3. Unknown field in a known aspect (e.g. zduTone on tagProperties, with a newer schemaVersion)

WhereBeforeAfter
ReadsCould fail validationField left out of the response; stored row unchanged
MCLs N wrote that fail validation hereFailed the batchDropped on their own, counted in invalid_mcl_skipped
System-update steps re-saving rowsRewrote or failedMigrateAspects leaves every row N wrote; the criterion-filter and global-settings steps leave N's rows that fail validation here. Each logs a warning
A save during the rollback window–Field is lost (accepted trade-off: N-1 can't keep what it can't read). The same applies if the criterion-filter step runs during a rollback: it re-saves N's rows that pass validation. It runs once per version, so after a rollback to a version that already ran it, it is skipped

4. Unknown enum value (e.g. incident type ZDU_DRIFT, owner type ZDU_STEWARD)

WhereBeforeAfter
GraphQL readsEvery entity in the batch failedNeutral fallback: incident type / owner type → CUSTOM, incident state → ACTIVE, policy → METADATA / INACTIVE
GraphQL object holding something it can't represent (incident on an unknown entity, policy with an unknown match condition, schema field of an unknown parent)The object was nulledObject returned with that field unset. The policy editor's list still leaves out policies with an unknown match condition, so a guessed condition can't be saved back
Writes to an aspect holding one–Rejected; stored value kept
Invalid-enum consistency checks (incl. assertion-invalid-type, which hard-deletes)Flagged N's data for deletionNot reported (rows from older versions still are)
Version set with a scheme only N defines–Adding a version is rejected, so N's scheme is not overwritten

5. Malformed MCP urn (e.g. urn:li:dataset:(urn:li:dataPlatform:hive,db.t missing ,PROD))

BeforeAfter
Kafka retried the poll 10 times, then discarded the whole poll, including valid MCPsWith entity/aspect tolerance on, only that MCP fails; the rest of the poll is saved. Counted in mcp.batch.malformed_urn (outcome=dropped). With it off, as before

Metrics: unknown_to_registry_skipped, unknown_references_kept, invalid_mcl_skipped (JMX), mcp.batch.malformed_urn (Prometheus). Logs are rate-limited to once a minute per place and type.

Testing

#RunEnvironmentResult
1Unit tests, full suites of the touched modules, including strict, tolerant and single-flag cases and flag binding against the shipped application.yaml; tolerance tests wired into the OpenSearch suiteGradle✅ 0 failed
2Live scenarios: reads, search, GraphQL, writes, Kafka, deletes, ingestion rollbackDocker quickstart (MySQL, Kafka, OpenSearch)✅ 0 failed
3N-1 end-to-end suite: N's rows, edges, Kafka events and API calls replayed against N-1Docker quickstart✅ 86 pass, 0 fail
4Flags off vs pre-PR buildDocker quickstart and Kubernetes✅ 46/46 scenarios behave the same as pre-PR. On Kubernetes: 156/156 checks the same as pre-PR, and system update fails at the same step
5Rolling upgrades and rollbacks across releases (N → N-1 → N, old releases → this change), 3 GMS replicas, standalone consumers, in-flight Kafka, mixed-version trafficKubernetes (helm)✅ 0 failures from this change
6Malformed MCP urnUnit tests + Kubernetes reproduction✅ before: whole poll discarded; after: valid MCPs stored
7Flag matrix: rollback with both kinds, entity/aspect only, enum only, neither; then the umbrella flag alone on the final codeKubernetes (helm)✅ Each kind tolerates only its own data, 0 anomalies; the umbrella flag alone passes every check

Bugs found during testing and review (all fixed in this PR)

Bug
Rest.li search naming only unknown types searched every type
Nested-key MCP dropped silently; known MCL in the same batch never indexed; ingestion rollback 500 past 10k rows
Version set with N's scheme overwritten; assertion-invalid-type proposed deleting N's assertion
Malformed MCP urn discarded the whole consumer poll
An incident, policy or schema field GraphQL couldn't fully represent was returned as null; now only the field it can't represent is unset
A write could not clear a field holding a hidden reference: the merge put it back
With a flag on, known data changed too (aggregated stats and timeseries reads treated known aspects differently, mixed-type batchGet was refetched per type). Now a flag changes only how unknown data is handled

Checklist

  • PR title follows the Contributing Guideline
  • Tests added/updated
  • Entry added in docs/how/updating-datahub.md

Summary by cubic

After a zero-downtime upgrade rollback, the previous version keeps working on data the newer version wrote instead of failing on it: anything the running registry doesn't know — entity types, aspects, fields, enum values — is skipped, left in place, and never stored or indexed, so rolling forward restores everything. An unknown entity type is tolerated only when a newer version registered it (a typo is still rejected); data the running version knows is handled exactly as before.

Migration

  • Tolerance is off by default. Set featureFlags.unknownDataToleranceEnabled (env UNKNOWN_DATA_TOLERANCE_ENABLED) to true to enable both kinds for a rollback; each kind's own env var overrides it: UNKNOWN_ENTITY_ASPECT_TOLERANCE_ENABLED (featureFlags.unknownEntityAspectToleranceEnabled) for entity types, aspects and references, and UNKNOWN_ENUM_TOLERANCE_ENABLED (featureFlags.unknownEnumToleranceEnabled) for enum symbols and union members. With all flags off, every path behaves as before this PR.

Behavior

  • A single skip rule covers unknown entity types, aspects and entity types nested in urn-key fields typed as urns; a string key field that just holds urn-shaped text isn't read as a reference. Reads fail per row rather than a whole batch, counting skips in unknown_to_registry_skipped and invalid_mcl_skipped.
  • Reads drop references to unknown entity types from known aspects, including references nested in urn keys, and mark the row as written by a newer version so re-save steps and indexing recognize it; writes keep the stored references at their position and reject a reference the stored row doesn't hold, so writing back what was read writes no version and a field the client saw and cleared isn't restored. List elements are matched by value, so a patched element whose numbers arrived re-typed isn't stored twice. A rollback that makes an older version the latest merges those references back from the stored row so they aren't lost.
  • MCL indexing strips the previous aspect like the new one, so a normal upgrade no longer deletes the newer version's edges and values through the index diff, and search diffs against the previous value with its unknown references removed so fields only it had are cleared; a DELETE still removes the previous aspect in full. An MCL whose new value is the newer version's is dropped and counted in invalid_mcl_skipped; one whose previous value alone is (the new value is valid) is indexed and counted in mcl_previous_from_newer_version_omitted, so search and the graph catch up with the change instead of keeping the old state.
  • GraphQL leaves out references, lineage hits, enum values, union members and policies it can't represent instead of failing a whole list or parent, and a data product's asset search likewise filters output ports of unknown entity types; OpenAPI and Rest.li return 400 for a request naming an unknown entity type or aspect. A malformed MCP urn is dropped and counted on its own without discarding the poll; a batch MCP the consumer drops is counted in mcp.batch.unknown_dropped.
  • Ingestion rollbacks page system metadata by position instead of from/size, fail a page they can't read, and report rows left in place in aspectsLeftInPlace (excluding rows of entities a hard rollback deletes); deletes resolve every aspect before deleting any, and consistency checks leave a newer version's assertions, invalid enums, and urns whose keys nest its entity types alone instead of flagging them, as the orphan check would otherwise delete entities still in SQL.
  • Upgrade steps that re-save stored rows leave newer-version rows as stored with a warning; LoadIndices classifies each row under the skipConversionErrors escape hatch and handles entity specs without a key aspect; Cassandra hard deletes also remove unknown stored aspects; searches drop underscored aliases; version sets with a newer scheme are rejected; tolerance tests run in the OpenSearch suite, and a lint test blocks new urn-derived registry lookups in server code.