Skip to content

Fix: Restoring lucene index build during startup & allow rebuild through UI - #2200

Merged
nscuro merged 3 commits into
DependencyTrack:masterfrom
syalioune:fix/allowing_lucene_index_rebuild
Dec 6, 2022
Merged

nscuro merged 3 commits into
DependencyTrack:masterfrom
syalioune:fix/allowing_lucene_index_rebuild

Conversation

@syalioune

@syalioune syalioune commented Nov 29, 2022 •

Copy link
Copy Markdown
Contributor

Description

Fix : Restoring lucene index build during startup by having a dedicated listener

The following features/fixes are introduced as part of this PR

  1. Index healthcheck at startup using a servlet listener. Healthcheck consist of index directory existence check and corruption check using lucene API. Any failure trigger rebuild of corresponding index
  2. A new configurable background task to perform health and consistency check. Healthcheck is the same one performed during startup. Concistency check consist of computing a delta ratio between DB and Lucene and comparing it to a configurable threshold. Any failure trigger rebuild of corresponding index
  3. Any Lucene CorruptIndexException will trigger a rebuild of the corresponding index
  4. A REST API (and corresponding GUI admin screen) is provided to manually rebuild the index if need be

#2235 is created to reduce as much as possible delta between DB and lucene that feature 2 above mitigate.

Addressed Issue

#2104

Additional Details

Related frontend PR DependencyTrack/frontend#338

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
    - [ ] This PR introduces changes to the database model, and I have added corresponding update logic
    - [ ] This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

53% of developers fix this issue

ImmutableEnumChecker: enums should be immutable: 'IndexType' has non-final field 'clazz'


Suggested change
private Class<?> clazz;
private final Class<?> clazz;

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@syalioune
syalioune force-pushed the fix/allowing_lucene_index_rebuild branch from 790b845 to 7b5b1cf Compare December 5, 2022 01:51
@syalioune
syalioune marked this pull request as ready for review December 5, 2022 01:55

@nscuro nscuro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @syalioune! 🚀

A few suggestions and nitpicks 😛

@nscuro

nscuro commented Dec 6, 2022

Copy link
Copy Markdown
Member

@syalioune Please rebase with master for the build to work again. The failure cause was fixed in #2241.

…d listener

A REST API is also exposed to allow index rebuild through the GUI. See DependencyTrack#2104
Automatic periodic consistency check with database are performed if enabled

Signed-off-by: Alioune SY <[email protected]>
…d listener

Takint into account review comments

Signed-off-by: Alioune SY <[email protected]>
…d listener

Fixing unit tests.

Signed-off-by: Alioune SY <[email protected]>
checkIndex.close();
}
} catch (IOException e) {
throw new RuntimeException(e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Finally: If you return or throw from a finally, then values returned or thrown from the try-catch block will be ignored. Consider using try-with-resources instead.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@nscuro nscuro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for yet again a stellar PR @syalioune! 🙌

@nscuro
nscuro merged commit c40c117 into DependencyTrack:master Dec 6, 2022
mulder999 pushed a commit to mulder999/dependency-track that referenced this pull request Dec 23, 2022
…dencyTrack#2200)

* Fix: Restoring lucene index build during startup by having a dedicated listener

A REST API is also exposed to allow index rebuild through the GUI. See DependencyTrack#2104
Automatic periodic consistency check with database are performed if enabled

Signed-off-by: Alioune SY <[email protected]>

* Fix: Restoring lucene index build during startup by having a dedicated listener

Takint into account review comments

Signed-off-by: Alioune SY <[email protected]>

* Fix: Restoring lucene index build during startup by having a dedicated listener

Fixing unit tests.

Signed-off-by: Alioune SY <[email protected]>

Signed-off-by: Alioune SY <[email protected]>

Fixes DependencyTrack#2104

Signed-off-by: mulder999 <[email protected]>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants