Repository navigation
Fix incident cleanup during recursive test-case deletion - #36983
Conversation
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · The new post-delete hook asynchronously removes incident history and test results during ancestor hard-deletion cascades, potentially erasing records users may need. Fixes orphaned incident rows left behind by recursive test-case deletion by scheduling incident cleanup from the hard-delete cascade hooks and deferring test case result cleanup until after commit. Resolved the per-test-case relationship query and async task in bulk hard-delete, and queued incident cleanup before the cascade transaction commits. No open issues found. ✅ 2 closed✅ Performance: Per-test-case relationship query and async task in bulk hard-delete
✅ Bug: Incident cleanup is queued before the cascade transaction commits
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 |
Describe your changes
Fixes
ReindexStatsIT.cleanRunBalancesReaderProcessorSink.Recursive table or service deletion bypassed
TestCaseRepository.deleteChildren, leaving incident rows behind after their parent test cases were removed. Later reindexing could read those orphan incidents and skip them because their parent relationships were missing.Capture incident IDs and test-case result FQNs before hard deletion, then submit asynchronous cleanup only after the owning database deletion succeeds. An enclosing transaction defers submission through
PostCommitActionQueueuntil commit and discards it on rollback. Both direct and bulk deletion use the samepreparePostDeleteCleanuphook.Incident discovery uses one batched relationship query per chunk, with deduplicated IDs. Each chunk schedules at most one incident-cleanup task and one result-cleanup task. The ancestor regression covers three sibling test cases; strict reader/processor accounting remains intact.
Two transaction-fix commits:
30c6dfdcd43: incident cleanup after successful hard deletion.a7c44338086: test-case result cleanup at the same lifecycle point.Type of change
High-level design
The cleanup preparation hook returns a closure containing the IDs/FQNs needed after relationship removal. Direct and bulk deletion invoke it through the post-commit queue only after their database deletion flush succeeds. This preserves asynchronous batching without treating the base executeEntityWrite hook as a transaction boundary. No schema, migration, or API contract changes.
Tests
Use cases covered
Unit tests
Current transaction fix:
TestCaseRepositoryTest11 passed, including deferred preparation and batched result deletion. The surrounding compile/verify command was stopped when it unexpectedly started broader integration infrastructure despite its skip flag; the unit-test results were complete.Historical broader run:
405 passed, 0 failures/errors/skips on merged HEAD
e9bb119bc14af67494c0349a3536e4a3ee177989:CreateTestCaseToolTest (4), MetricObservabilityBuilderTest (22), ODCSImportAnalyzerTest (13), ODCSQualityRuleImporterTest (15), ReindexingUtilDocBuildContextTest (7), SearchIndexFactoryTest (290), SearchRepositoryTest (25), TestCaseIndexTest (13), TestCaseRepositoryTest (11), TestSuiteRepositoryTest (5).
Coverage percentage has not been measured. The cleanup regression is exercised through real API/database integration tests rather than mocked repository interactions.
Backend integration tests
Current HEAD
a7c44338086d53676011230914ffd44600287280:EntityHardDeletionAtomicityIT: 18 passed, including direct/bulk × commit/rollback/SQL failure/deadlock retry for incidents and results.TestCaseResourceIT#test_recursiveHardDeleteCascadesPastResolutionStatusChildren+test_hardDeleteReapsResolutionStatusChildren: 2 passed.ReindexDocSurvivalIT,ReindexStatsIT: 6 passed.Historical validation:
Before merging upstream/main, the final asynchronous implementation passed:
TestCaseResourceIT#test_recursiveHardDeleteCascadesPastResolutionStatusChildren+test_hardDeleteReapsResolutionStatusChildren: 2 passed on PostgreSQL/OpenSearch.ReindexDocSurvivalIT,ReindexStatsIT, alphabetical order: 6 passed on PostgreSQL/OpenSearch.mvn -B -pl openmetadata-service,openmetadata-integration-tests spotless:apply spotless:checkpassed.Earlier batching fix
bc58b61d9a94133dc9eb59e26604a6586eb45691:ReindexDocSurvivalIT,ReindexStatsIT: 6 passed, 0 failures/errors/skips, PostgreSQL/OpenSearch.Broader affected-test validation on the previous commit
e9bb119bc14astopped at MySQL startup (connection refused): 405 unit tests passed; zero integration tests ran. Remaining broad steps were not run. Full affected-suite validation remains incomplete; the current focused results are listed separately above. The full affected suite has not been completed for the new shared lifecycle hook.Local Java test run: FAILED
e9bb119bc14a(baseupstream/main)Selected but produced no report:
ApiLatencyRecorderTest (mysql-elasticsearch · parallel),AppEventSubscriptionRemovalIT (mysql-elasticsearch · parallel),AppTriggerConflictIT (mysql-elasticsearch · parallel),AutoAssignIncidentIT (mysql-elasticsearch · parallel),AutoCloseIncidentIT (mysql-elasticsearch · parallel),ConfigResourceIT (mysql-elasticsearch · parallel),ConnectionSecretsMigrationIT (mysql-elasticsearch · parallel),ContextMemorySearchMatrixIT (mysql-elasticsearch · parallel),DataContractPermissionIT (mysql-elasticsearch · parallel),DataContractResourceIT (mysql-elasticsearch · parallel)and 114 more in the detailsIngestion integration tests
N/A — no ingestion changes.
Playwright (UI) tests
N/A — no UI changes.
Manual testing performed
No manual UI testing. Automated regressions create a test case and incident, delete either the case or its ancestor through the API, and wait for incident rows and relationships to disappear.
UI screen recording
N/A — backend-only bug fix.
Checklist
skip-pr-checkslabel; no separate issue.a7c44338086d53676011230914ffd44600287280againstREVIEW.md; no findings.Summary by Gitar
PostCommitActionQueue.runOrDefertest_case_resolution_statuschild IDs before relationship removal, so cleanup survives rollback and failurepreparePostDeleteCleanuptoEntityRepositoryfor capturing cleanup inputs before hard deletionEntityHardDeletionAtomicityITcovering commit, rollback, failure, and retry outcomesReindexStatsITnow asserts zero reader failures on clean runsThis will update automatically on new commits.