-
Notifications
You must be signed in to change notification settings - Fork 67
[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
base: main
Are you sure you want to change the base?
Conversation
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.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
valeriy42
left a comment
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.
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.
| isInputFileNamedPipe, outputFileName, isOutputFileNamedPipe, quantilesStateFile, | ||
| deleteStateFiles, writeCsv, validElasticLicenseKeyConfirmed); | ||
|
|
||
| if (!quantilesStateFile.empty()) { |
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.
If understand this correctly, since the RAII guard was created before the logger reconfiguration, if something will fail, the LOG_WARN message in Line 64 will be logged in stderr instead of the logging named pipe.
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.
Yes, any logging prior to the logger reconfiguration to use a named pipe as the sink will go to stderr. Which is unfortunate but not a disaster.
bin/normalize/Main.cc
Outdated
| } | ||
| 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()); |
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.
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.).
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.
Also, it would be consistent with the happy path behavior to delete the quantile files only when --deleteStateFiles is set.
bin/normalize/Main.cc
Outdated
| // 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()); |
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.
Here again, it would be good to check the return value of std::remove and log success or failure with errno.
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.