Skip to content

Issue 3721 - #4003

Merged
harshach merged 2 commits into
mainfrom
issue-3721
Apr 11, 2022
Merged

harshach merged 2 commits into
mainfrom
issue-3721

Conversation

@harshach

Copy link
Copy Markdown
Collaborator

Describe your changes :

I worked on the ..... because ...

Type of change :

  • Bug fix
  • [] Documentation

Frontend Preview (Screenshots) :

For frontend related change, please link screenshots of your changes preview! Optional for backend related changes.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • All new and existing tests passed.

Reviewers

@github-actions

Copy link
Copy Markdown
Contributor

Schema Change Detected. Needs ingestion-core version bump

Please run make core_bump_version_dev in the project's root and commit the changes to _version.py in this PR. Please ignore if this has been handled already.

@sonarqubecloud

Copy link
Copy Markdown

[catalog] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@harshach
harshach requested a review from sureshms April 11, 2022 02:32
@harshach
harshach merged commit 5d2a5c2 into main Apr 11, 2022
@harshach
harshach deleted the issue-3721 branch April 11, 2022 04:44
harshach added a commit that referenced this pull request May 8, 2026
…cade

Two follow-up improvements to the bulk restore introduced for #4003.

Batched findTo per tree level: bulkRestoreSubtree previously issued one
findTo per parent during recursion, which at the schemas → tables level
of a 12k-table database meant 12k DB round trips just to enumerate
children. The new bulkRestoreContainedChildren helper does one
findToBatchAllTypes per tree level regardless of fan-out, then groups
the results by child type and dispatches to each repo's
bulkRestoreSubtree. DashboardRepository's chart-restore logic moves
from the now-bypassed restoreChildren override to the existing
restoreAdditionalChildren extension hook so it still runs both for
direct dashboard restores and when dashboards are descendants of a
larger restore.

Symmetric bulk soft-delete cascade: deleteByName/deleteById had the
same per-entity recursion that this PR fixed for restore — soft-
deleting a database with 12k tables ran 12k recursive
Entity.deleteEntity calls, each writing one row + one ES update + one
change event. New bulkSoftDeleteSubtree mirrors bulkRestoreSubtree:
one batched findToBatchAllTypes per level, deferred-store DB writes,
batched version history, batched change events, batched cache
invalidation; per-descendant ES writes are skipped because the existing
deleteFromSearch cascade flips the deleted flag on descendant indexes
in one update_by_query. deleteChildren(List, hardDelete=false, ...)
now dispatches to the bulk path; hard-delete keeps the existing
batchDeleteChildren path. New softDeleteAdditionalChildren extension
hook mirrors restoreAdditionalChildren; DashboardRepository's chart
soft-delete migrates onto it for the same reason.

Tests: extends EntityRepositoryRestoreTest with cases that verify
findToBatchAllTypes is invoked exactly once per level (not once per
parent) for both bulk operations, plus the existing grouping/dispatch
shape for the soft-delete entry point. Extends RestoreHierarchyIT
with a recursive soft-delete cascade assertion.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
harshach added a commit that referenced this pull request May 12, 2026
So mark-deletion cascades during ingestion stop blocking on the server's
recursive walk (issue #4003 mirror on the ingestion side).

Legacy OpenMetadata client:
- delete_async(entity, id, recursive, hard_delete) hits
  DELETE /<entity>/async/{id}?recursive=...&hardDelete=...
- restore_async(entity, id) hits PUT /<entity>/restore?async=true
Both return the 202 payload (jobId + message) so the caller can correlate
the dispatch with WebSocket notifications.

Sink integration:
- DeleteEntity model gains a dispatch_async flag (default False).
- delete_entity_from_source / delete_entity_by_name accept an explicit
  dispatch_async= or fall back to the OM_INGESTION_DELETE_ASYNC env var
  via _default_dispatch_async(). This lets operators flip the entire
  ingestion process to async cascades with a single env var, with no
  per-connector schema changes.
- MetadataRestSink.delete_entity routes through metadata.delete_async
  when DeleteEntity.dispatch_async is set, logging the returned jobId
  for operator correlation.

Backend tweaks:
- EntityResource.restoreEntityAsync's pre-check now distinguishes the
  two raw EntityNotFoundException failure modes — 404 if the entity
  truly doesn't exist (Include.ALL still misses) vs 400 if it exists
  but isn't soft-deleted.
- Add a Javadoc "operational ceiling" note to bulkRestoreSubtree /
  bulkSoftDeleteSubtree calling out the single-@transaction shape and
  the implication for concurrent restores against a small DB pool;
  chunked-transaction support tracked as a follow-up.

Tests:
- New pytest cases in test_ometa_restore.py for the two async client
  methods (URL shape + 202 payload pass-through).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
harshach added a commit that referenced this pull request May 21, 2026
* fix(restore): bulk + async restore for large entity hierarchies

EntityRepository.restoreEntity walked descendants synchronously, taking
4+ minutes on a 12k-table database and exceeding typical proxy timeouts.
restoreChildren now groups CONTAINS children by type and dispatches one
bulkRestoreSubtree per type, batching DB writes, version history,
change events, and cache invalidation; the existing ES cascade handles
descendant index updates in one update_by_query.

Adds an async option (?async=true) on the deep-hierarchy restore
endpoints that returns 202 Accepted with a job id and runs the restore
on AsyncService, emitting WebSocket notifications on
restoreEntityChannel. Java SDK adds .restore().async().execute() fluent
builders on Tables/Databases plus restoreServerAsync on
EntityServiceBase; Python SDK mirrors this with
restore_request().with_async().execute() and restore_async() helpers
on BaseEntity, exposing a new AsyncJobResponse type.

Tests: EntityRepositoryRestoreTest verifies the per-type grouping and
bulk dispatch path; RestoreFluentAPITest covers the Java SDK fluent
behavior; RestoreHierarchyIT exercises sync and async restore against a
real DB→schemas→tables tree end-to-end; test_restore_async.py covers
the Python SDK paths.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant