-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Fix inefficient (worst case exponential) loading of snapshot repository #24510
Conversation
…ry data when checking for incompatible snapshots.
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
* @param snapshotId snapshot id | ||
* @return information about snapshot | ||
*/ | ||
SnapshotInfo getSnapshotInfo(RepositoryData repositoryData, SnapshotId snapshotId); |
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.
I appreciate that requiring to pass RepositoryData on getSnapshotInfo might not be the cleanest solution regarding Repository's API.
@joachimdraeger thank you for this contribution, and great catch! Indeed this would help solve the performance issues introduced by Let me know if you have the time to do this, or if you prefer I take it on. We would want to get this in for 5.4.1 and 5.5.0. Thanks again! Regarding your question of running |
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.
I left feedback on a different approach
@abeyad thanks for your feedback. I see that the incompatible SnapshotInfo is only used for the list. In get and restore incompatible is determined twice at the moment: directly and in getSnapshotInfo. I think it would be nicer in general if the source of truth would be getSnapshotInfo with the INCOMPATIBLE state in all cases. However, that would require a much bigger refactoring. For now I agree that removing the check from 'getSnapshotInfo' and letting 'SnapshotsService#snapshots' check for incompatible snapshots itself seems to be the most viable solution. I'm happy to give it a go on Monday. |
Thank you @joachimdraeger, don't hesitate to ping me on Monday if I can help in any way. |
…repository data" This reverts commit 6eb9837.
@abeyad I re-implemented the fix as discussed. I tested the incompatible snapshots listing manually and the performance improvement. |
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.
I left a couple small comments. Once fixed, we can get this merged.
// an incompatible snapshot - cannot read its snapshot metadata file, just return | ||
// a SnapshotInfo indicating its incompatible | ||
return SnapshotInfo.incompatible(snapshotId); | ||
} |
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.
Since getSnapshotInfoInternal
(just below) is only used by getSnapshotInfo
, we can move the code in getSnapshotInfoInternal
directly into getSnapshotInfo
and get rid of getSnaphotInfoInternal
@@ -196,6 +206,7 @@ public SnapshotInfo snapshot(final String repositoryName, final SnapshotId snaps | |||
return Collections.unmodifiableList(snapshotList); | |||
} | |||
|
|||
|
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.
remove extra new line
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.
LGTM, I will run the tests locally as well and merge. Thank you for working on this @joachimdraeger!
@elasticmachine test this please |
This commit fixes inefficient (worst case exponential) loading of snapshot repository data when checking for incompatible snapshots, that was introduced in #22267. When getting snapshot information, getRepositoryData() was called on every snapshot, so if there are a large number of snapshots in the repository and _all snapshots were requested, the performance degraded exponentially. This commit fixes the issue by only calling getRepositoryData once and using the data from it in all subsequent calls to get snapshot information. Closes #24509
This commit fixes inefficient (worst case exponential) loading of snapshot repository data when checking for incompatible snapshots, that was introduced in #22267. When getting snapshot information, getRepositoryData() was called on every snapshot, so if there are a large number of snapshots in the repository and _all snapshots were requested, the performance degraded exponentially. This commit fixes the issue by only calling getRepositoryData once and using the data from it in all subsequent calls to get snapshot information. Closes #24509
@joachimdraeger the PR has been merged - thanks again! |
@abeyad are you sure this change was made properly into I am seeing that there is a rogue reference to the seems to be the only call to it... but the method definition is deleted. |
* master: Increase compilation limit in ingest tests Mark 6.0.0-alpha1 as prerelease Updated release notes for 6.0.0-alpha1 Fix single shard scroll within a cluster with nodes in version >= 5.3 and <= 5.3 (elastic#24512) add option for _ingest.timestamp to use new ZonedDateTime (elastic#24030) Fixes inefficient loading of snapshot repository data (elastic#24510) Scripting: Deprecate file scripts (elastic#24552) Remove commented code from ESILRTC Ensure test replicas have valid recovery state Add global checkpoint assertion in index shard Improve bootstrap checks error messages Refactor UpdateHelper into unit-testable pieces Fix cache expire after access Document work-around for jar hell in idea_rt.jar file (elastic#24523) Move MockLogAppender to elasticsearch test (elastic#24542) Remove gap skipping when opening engine documentation of preserve existing settings remove duplicated import in AppendProcessor
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Ensure that getRepositoryData() is only called once during a list snapshots operation. Fixes #24509.