-
-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimized synchronizeVulnerability #4359
Conversation
This modification is in order to avoid multiple writes and/or updates when there is no changes. Part of the logic in updateVulnerability was optimized. Add differ.applyIfChanged and callInTransaction. SynchronizeVulnerability returns null if there is nothing to synchronize. Some modifications were needed to couple with new logic. e.g. if (SynchronizeVulnerability = null) continue. Test are provided. Signed-off-by: Andres Tito <[email protected]>
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @LaVibeX! Looks good, just some minor suggestions.
src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java
Outdated
Show resolved
Hide resolved
src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java
Outdated
Show resolved
Hide resolved
src/main/java/org/dependencytrack/persistence/VulnerabilityQueryManager.java
Outdated
Show resolved
Hide resolved
-Remove unnecesary persistance in updateVulnerability function. -Return updated exisitingVulnerability in updateVulnerability -Remove return of empty vulnerability -Wrap synchronizedVUlnerability in callInTransaction to share same transaction. Signed-off-by: Andres Tito <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Description
This modification is intended to avoid multiple updates/writes in the database when there are no changes. In general we want to reduce unnecessary load on the DB.
Part of the logic in updateVulnerability was optimized. The differ.applyIfChanged method was added, similar to what NIST is doing
dependency-track/src/main/java/org/dependencytrack/tasks/AbstractNistMirrorTask.java
Lines 222 to 257 in 8087a94
dependency-track/src/main/java/org/dependencytrack/persistence/NotificationQueryManager.java
Lines 162 to 171 in 7ce8e04
synchronizeVulnerability now returns null if there is nothing to synchronize.
Some modifications were needed to align with the new logic. For example:
if (synchronizeVulnerability == null) continue;
Tests are provided.
Addressed Issue
Closes #3922
Additional Details
Checklist