Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ML] Better cleanup of normalizer quantiles state #2894

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

Open
edsavage wants to merge 8 commits into elastic:main
base: main
Choose a base branch
Loading
from edsavage:normalizer_quantile_state_cleanup

Conversation

@edsavage
Copy link
Contributor

@edsavage edsavage commented Jan 26, 2026

Ensure that quantiles state documents are always removed after an error has been encountered. This is intended to stop the disk being cluttered with many such documents after repeated failures.

Ensure that quantiles state documents are always removed after an error has been encountered. This is intended to stop the disk being cluttered with many such documents after repeated failures.
Copy link

prodsecmachine commented Jan 26, 2026
edited
Loading

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Contributor

@valeriy42 valeriy42 left a comment

Choose a reason for hiding this comment

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

Thank you for addressing this issue. I have a couple of quick comments.

A more general comment: we have the same situation in bin/autodetect/Main.cc. Maybe you can generalize the RAII guard and use it in both cases.

edsavage reacted with thumbs up emoji
}
LOG_WARN(<< "Deleting quantiles state file '" << m_QuantilesStateFile << "'");
// Ignore the return value from remove, the file may have already been deleted.
std::remove(m_QuantilesStateFile.c_str());
Copy link
Contributor

@valeriy42 valeriy42 Jan 26, 2026

Choose a reason for hiding this comment

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

You need to check the return value of std::remove and log if the files could not be deleted for some reason (permissions, locked file, etc.).

edsavage reacted with thumbs up emoji
Copy link
Contributor

@valeriy42 valeriy42 Jan 26, 2026

Choose a reason for hiding this comment

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

Also, it would be consistent with the happy path behavior to delete the quantile files only when --deleteStateFiles is set.

edsavage reacted with thumbs up emoji
// No need for a warning here so we reset the cleanup function and delete the file explicitly if requested.
removeQuantilesStateOnFailure.reset();
if (deleteStateFiles) {
std::remove(quantilesStateFile.c_str());
Copy link
Contributor

@valeriy42 valeriy42 Jan 26, 2026

Choose a reason for hiding this comment

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

Here again, it would be good to check the return value of std::remove and log success or failure with errno.

Copy link
Contributor

@valeriy42 valeriy42 left a comment

Choose a reason for hiding this comment

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

LGTM. Great work. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@valeriy42 valeriy42 valeriy42 approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /