Skip to content

Fix: Resolve duplicate loop operations in TestCaseRepository#27448

Open
aniruddhaadak80 wants to merge 1 commit intoopen-metadata:mainfrom
aniruddhaadak80:fix-testcase-repository-nested-loop-bug-27060
Open

Fix: Resolve duplicate loop operations in TestCaseRepository#27448
aniruddhaadak80 wants to merge 1 commit intoopen-metadata:mainfrom
aniruddhaadak80:fix-testcase-repository-nested-loop-bug-27060

Conversation

@aniruddhaadak80
Copy link
Copy Markdown

@aniruddhaadak80 aniruddhaadak80 commented Apr 17, 2026

Resolves issue #27060. The loop calling deleteChildren was incorrectly placed inside another loop, turning an O(N) deletion operation to O(N^2) against testcases. Also removes redundant AsyncExecutor deletion block

@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Apr 17, 2026

Code Review ✅ Approved

Refactored TestCaseRepository to eliminate O(N^2) duplication, improving overall data processing efficiency. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an inefficient deletion path in the backend TestCaseRepository that caused redundant (O(N²)) deletions of TestCaseResolutionStatus children and also removed a duplicate deletion of test case results that was executed both synchronously and asynchronously.

Changes:

  • Fix deleteChildren() to perform a single pass over child records (O(N)) and instantiate the TestCaseResolutionStatusRepository once.
  • Remove the redundant async deletion block in deleteAllTestCaseResults() and delete exactly once.
  • Remove the now-unused ExecutorService/Executors field and imports.

@aniruddhaadak80 aniruddhaadak80 changed the title Fix: Resolve O(N^2) duplication in TestCaseRepository #27060 Fix: Resolve duplicate loop operations in TestCaseRepository Apr 17, 2026
@aniruddhaadak80 aniruddhaadak80 force-pushed the fix-testcase-repository-nested-loop-bug-27060 branch from 7311a54 to cff7175 Compare April 22, 2026 05:40
@github-actions
Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

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.

2 participants