-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Historical unloads damaged segments automatically when lazy on start. #10688
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
Merged
clintropolis
merged 34 commits into
apache:master
from
zhangyue19921010:historical-lazyOnStart-with-fileCheck
Jan 17, 2021
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
0a6eb30
ready to test
4c3e697
tested on dev cluster
7775658
tested
6b9595e
code review
ff6deb5
add UTs
9fefdff
add UTs
13710d9
ut passed
f67b334
ut passed
7dd33e2
opti imports
dd4fd45
Merge branch 'master' into historical-lazyOnStart-with-fileCheck
eac8919
done
e1eca76
done
3d567da
fix checkstyle
34f98f0
Merge branch 'master' into historical-lazyOnStart-with-fileCheck
6b82e6c
modify uts
c573772
Merge branch 'master' into historical-lazyOnStart-with-fileCheck
f113ed3
modify logs
5bfca47
changing the package of SegmentLazyLoadFailCallback.java to org.apach…
6284c5f
Merge branch 'master' into historical-lazyOnStart-with-fileCheck
c7d9115
merge from master
ba5dd23
modify import orders
5c89232
merge from master
7714f81
merge from master
65f17df
modify logs
dd46d75
modify docs
15a4c3e
modify logs to rerun ci
80accce
modify logs to rerun ci
78f5ff3
modify logs to rerun ci
9dec7bd
modify logs to rerun ci
6bb59ce
modify logs to rerun ci
b5aa610
modify logs to rerun ci
4fdbc25
Merge branch 'master' into historical-lazyOnStart-with-fileCheck
a510bee
modify logs to rerun ci
fef72a7
modify logs to rerun ci
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,16 +182,17 @@ public void validateTwoSegments(final IndexableAdapter adapter1, final Indexable | |
|
|
||
| public QueryableIndex loadIndex(File inDir) throws IOException | ||
| { | ||
| return loadIndex(inDir, false); | ||
| return loadIndex(inDir, false, SegmentLazyLoadFailCallback.NOOP); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add blank line here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
| public QueryableIndex loadIndex(File inDir, boolean lazy) throws IOException | ||
|
|
||
| public QueryableIndex loadIndex(File inDir, boolean lazy, SegmentLazyLoadFailCallback loadFailed) throws IOException | ||
| { | ||
| final int version = SegmentUtils.getVersionFromDir(inDir); | ||
|
|
||
| final IndexLoader loader = indexLoaders.get(version); | ||
|
|
||
| if (loader != null) { | ||
| return loader.load(inDir, mapper, lazy); | ||
| return loader.load(inDir, mapper, lazy, loadFailed); | ||
| } else { | ||
| throw new ISE("Unknown index version[%s]", version); | ||
| } | ||
|
|
@@ -412,7 +413,7 @@ public MMappedIndex mapDir(File inDir) throws IOException | |
|
|
||
| interface IndexLoader | ||
| { | ||
| QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy) throws IOException; | ||
| QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy, SegmentLazyLoadFailCallback loadFailed) throws IOException; | ||
| } | ||
|
|
||
| static class LegacyIndexLoader implements IndexLoader | ||
|
|
@@ -427,7 +428,7 @@ static class LegacyIndexLoader implements IndexLoader | |
| } | ||
|
|
||
| @Override | ||
| public QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy) throws IOException | ||
| public QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy, SegmentLazyLoadFailCallback loadFailed) throws IOException | ||
| { | ||
| MMappedIndex index = legacyHandler.mapDir(inDir); | ||
|
|
||
|
|
@@ -522,7 +523,7 @@ static class V9IndexLoader implements IndexLoader | |
| } | ||
|
|
||
| @Override | ||
| public QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy) throws IOException | ||
| public QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy, SegmentLazyLoadFailCallback loadFailed) throws IOException | ||
| { | ||
| log.debug("Mapping v9 index[%s]", inDir); | ||
| long startTime = System.currentTimeMillis(); | ||
|
|
@@ -598,7 +599,9 @@ public QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy) throws | |
| try { | ||
| return deserializeColumn(mapper, colBuffer, smooshedFiles); | ||
| } | ||
| catch (IOException e) { | ||
| catch (IOException | RuntimeException e) { | ||
| log.warn(e, "Throw exceptions when deserialize column [%s].", columnName); | ||
| loadFailed.execute(); | ||
| throw Throwables.propagate(e); | ||
| } | ||
| } | ||
|
|
@@ -618,7 +621,9 @@ public QueryableIndex load(File inDir, ObjectMapper mapper, boolean lazy) throws | |
| try { | ||
| return deserializeColumn(mapper, timeBuffer, smooshedFiles); | ||
| } | ||
| catch (IOException e) { | ||
| catch (IOException | RuntimeException e) { | ||
| log.warn(e, "Throw exceptions when deserialize column [%s]", ColumnHolder.TIME_COLUMN_NAME); | ||
| loadFailed.execute(); | ||
| throw Throwables.propagate(e); | ||
| } | ||
| } | ||
|
|
||
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
26 changes: 26 additions & 0 deletions
26
processing/src/main/java/org/apache/druid/segment/SegmentLazyLoadFailCallback.java
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,26 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.segment; | ||
|
|
||
| public interface SegmentLazyLoadFailCallback | ||
| { | ||
| void execute(); | ||
| SegmentLazyLoadFailCallback NOOP = () -> {}; | ||
| } |
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
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
Binary file added
BIN
+1.55 KB
processing/src/test/resources/v9SegmentPersistDir/segmentWithDamagedFile/00000.smoosh
Binary file not shown.
1 change: 1 addition & 0 deletions
1
processing/src/test/resources/v9SegmentPersistDir/segmentWithDamagedFile/factory.json
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 @@ | ||
| {"type":"mMapSegmentFactory"} |
9 changes: 9 additions & 0 deletions
9
processing/src/test/resources/v9SegmentPersistDir/segmentWithDamagedFile/meta.smoosh
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,9 @@ | ||
| v1,2147483647,1 | ||
| __time,0,0,141 | ||
| count,0,141,282 | ||
| dstIP,0,564,805 | ||
| index.drd,0,1046,1205 | ||
| metadata.drd,0,1205,1587 | ||
| srcIP,0,805,1046 | ||
| sum_bytes,0,282,423 | ||
| sum_packets,0,423,564 |
Binary file added
BIN
+4 Bytes
processing/src/test/resources/v9SegmentPersistDir/segmentWithDamagedFile/version.bin
Binary file not shown.
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
Oops, something went wrong.
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.
what is this change for?
Uh oh!
There was an error while loading. Please reload this page.
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.
Current UTs don't cover
load segment in a lazy way. This PR add a UT to test lazy loading which needs extra memory.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.
👍 was just surprised how much more it needed, if travis passes then I assume the change is fine, was just curious mostly