-
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
Open
edsavage
wants to merge
8
commits into
elastic:main
Choose a base branch
from
edsavage:normalizer_quantile_state_cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+119
−20
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e08c9a3
[ML] Better cleanup of normalizer quantiles state
edsavage 06c44d2
Update changelog
edsavage dcd94db
Attend to review comments
edsavage 95e1486
Reuse quantile state file deleter for autodetect as well as normalizer
edsavage 1713588
Log a warning message if unable to remove quantiles state file.
edsavage 30d2103
Tweak changelog entry to be more generic.
edsavage b033c7c
Tighten up usage of CStateRestorer.
edsavage 9ee974c
Formatting
edsavage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the following additional limitation. Functionality enabled by the | ||
| * files subject to the Elastic License 2.0 may only be used in production when | ||
| * invoked by an Elasticsearch process with a license key installed that permits | ||
| * use of machine learning features. You may not use this file except in | ||
| * compliance with the Elastic License 2.0 and the foregoing additional | ||
| * limitation. | ||
| */ | ||
| #ifndef INCLUDED_ml_core_CStateFileRemover_h | ||
| #define INCLUDED_ml_core_CStateFileRemover_h | ||
|
|
||
| #include <core/CLogger.h> | ||
|
|
||
| #include <cstdlib> | ||
|
|
||
| namespace ml { | ||
| namespace core { | ||
|
|
||
| //! \brief | ||
| //! Ensures that deletion of state files occurs even on process failure. | ||
| //! | ||
| //! DESCRIPTION:\n | ||
| //! A helper to ensure that quantiles state files always get deleted on failure. | ||
| //! They may also be explicitly be deleted on request as well but that is handled separately by the happy path. | ||
| //! | ||
| //! IMPLEMENTATION DECISIONS:\n | ||
| //! Not copyable or moveable. No default construction. | ||
| class CStateFileRemover { | ||
| public: | ||
| CStateFileRemover() = delete; | ||
| CStateFileRemover(const CStateFileRemover&) = delete; | ||
| CStateFileRemover& operator=(const CStateFileRemover&) = delete; | ||
| CStateFileRemover(CStateFileRemover&&) = delete; | ||
| CStateFileRemover& operator=(CStateFileRemover&&) = delete; | ||
| explicit CStateFileRemover(const std::string& quantilesStateFile, | ||
| bool deleteStateFiles = false) | ||
| : m_QuantilesStateFile{quantilesStateFile}, m_DeleteStateFiles{deleteStateFiles} {} | ||
| ~CStateFileRemover() { | ||
| // Always delete quantiles state files if requested to do so, even on failure, | ||
| // else we run the risk of filling the disk after repeated failures. | ||
| // They should still exist in ES should they need to be examined. | ||
| if (m_QuantilesStateFile.empty() || m_DeleteStateFiles == false) { | ||
| return; | ||
| } | ||
| LOG_DEBUG(<< "Deleting quantiles state file '" << m_QuantilesStateFile << "'"); | ||
| if (std::remove(m_QuantilesStateFile.c_str()) != 0) { | ||
| LOG_WARN(<< "Failed to delete quantiles state file '" | ||
| << m_QuantilesStateFile << "': " << strerror(errno)); | ||
| } | ||
| } | ||
|
|
||
| private: | ||
| std::string m_QuantilesStateFile; | ||
| bool m_DeleteStateFiles{false}; | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| #endif // INCLUDED_ml_core_CStateFileRemover_h |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.