Skip to content

fix(scanner): optimize removal of immutable scanners with bulk deletion - #24023

Open
vishalmore90 wants to merge 1 commit into
goharbor:mainfrom
vishalmore90:fix-issue-24022
Open

vishalmore90 wants to merge 1 commit into
goharbor:mainfrom
vishalmore90:fix-issue-24022

Conversation

@vishalmore90

Copy link
Copy Markdown

Comprehensive Summary of your change

This PR resolves an N+1 query performance issue in the RemoveImmutableScanners initialization step.

Previously, when clearing out old immutable scanners, RemoveImmutableScanners retrieved all relevant scanner registrations from the database and executed an individual DELETE query for each scanner in a loop. For setups with multiple scanners being cycled or cleared out, this generated unnecessary DB traffic and latency.

This PR implements a bulk-deletion method (DeleteRegistrations) in the scanner data access object (dao/scanner/registration.go), wires it through the scanner Manager interface as DeleteBy, and updates RemoveImmutableScanners in init.go to use this new method. It completely replaces the N+1 DELETE loop with a single bulk query, resolving the documented TODO. Unit tests and mocks have been appropriately updated and verified.

Issue being fixed

Fixes #24022

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

Signed-off-by: vishal <httpsvishal07@gmail.com>

This branch has not been deployed

No deployments
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.

N+1 database queries during immutable scanner registration removal (RemoveImmutableScanners)

4 participants