Fixes #27418: optimize test case hard-delete relationship cleanup#27633
Fixes #27418: optimize test case hard-delete relationship cleanup#27633Megh-Shah-08 wants to merge 9 commits intoopen-metadata:mainfrom
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
There was a problem hiding this comment.
Pull request overview
Optimizes cleanup of testCaseResolutionStatus relationships when deleting TestCase entities (and during retention cleanup) to avoid per-relationship deletion overhead and prevent orphaned relationship rows.
Changes:
- Added a batch relationship cleanup path for all resolution-status records associated with a TestCase FQN.
- Hooked the optimized cleanup into TestCase hard-delete lifecycle and the Data Retention app.
- Updated time-series hard-delete behavior to also remove relationships; added an integration test covering the cleanup behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java | Adds bulk relationship cleanup by TestCase and changes relationship type used for linking TestCase ↔ ResolutionStatus. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseRepository.java | Calls the new resolution-status relationship cleanup during TestCase entity-specific hard-delete cleanup. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityTimeSeriesRepository.java | Ensures hard-deleting a time-series record also deletes its relationships. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java | Adds DAO method to delete orphaned relationships based on missing “from” entity rows. |
| openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataRetention/DataRetention.java | Adds retention-job step to remove orphaned TestCase → ResolutionStatus relationship rows. |
| openmetadata-service/src/main/java/org/openmetadata/service/Entity.java | Special-cases time-series entities in Entity.deleteEntity to avoid standard delete flow. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestCaseResourceIT.java | Adds integration test asserting relationships are removed while time-series history remains. |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi @ayush-shah, I’ve addressed the majority of the Copilot and Gitar review comments, including performance improvements and backward compatibility concerns. Thanks! |
🟡 Playwright Results — all passed (15 flaky)✅ 3958 passed · ❌ 0 failed · 🟡 15 flaky · ⏭️ 86 skipped
🟡 15 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
3dae659 to
719c773
Compare
162e793 to
3c90701
Compare
…e relationship cleanup
|
Hi @ayush-shah, Some tests are failing here. Could you review and let me know what's blocking? |
ayush-shah
left a comment
There was a problem hiding this comment.
Detailed code review findings from Codex.
… remove redundant DAO method
Code Review ✅ Approved 6 resolved / 6 findingsOptimizes test case hard-delete relationship cleanup by resolving issues with unused variables, SQL injection risks, and inconsistent entity deletion logic. All identified technical debt and safety concerns have been addressed. ✅ 6 resolved✅ Quality: Unused variable in Entity.deleteEntity early return
✅ Bug: PARENT_OF→RELATED_TO change breaks existing data without migration
✅ Edge Case: Entity.deleteEntity silently swallows deletes for TS entities
✅ Edge Case: deleteById relationship cleanup applies to all TS entities
✅ Security: @define table param enables SQL injection surface
...and 1 more resolved from earlier reviews OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|



Describe your changes:
Fixes #27418
Summary: Optimized the cleanup of TestCaseResolutionStatus relationships during TestCase hard-deletes. Replaced an inefficient$O(N)$ sequential deletion loop with a single set-based SQL delete.
Root Cause: The repository was iterating through each relationship and deleting them one-by-one. This caused significant database round-trip overhead for test cases with large incident histories.
Changes:
How I tested:
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>Summary by Gitar
deleteOrphanedRelationshipsusingLIMITclauses to avoid large transaction overhead.deleteFromDAO method to allow efficientTestCaseResolutionStatusrelationship removal.EntityTimeSeriesRepositoryto only trigger relationship cleanup if the base entity deletion was successful.This will update automatically on new commits.