-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-9819. Recon - Potential memory overflow in Container Health Task. #5841
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
Changes from 5 commits
6f411d1
c77e3d5
7a7e68f
88b671f
1a2c4ce
720d24b
81f271c
903805a
8612090
0abeec2
1fb54db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ | |
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import static org.apache.hadoop.ozone.recon.ReconConstants.CONTAINER_COUNT; | ||
| import static org.apache.hadoop.ozone.recon.ReconConstants.DEFAULT_FETCH_COUNT; | ||
| import static org.apache.hadoop.ozone.recon.ReconConstants.TOTAL_KEYS; | ||
| import static org.apache.hadoop.ozone.recon.ReconConstants.TOTAL_USED_BYTES; | ||
|
|
||
|
|
@@ -131,8 +132,23 @@ public void triggerContainerHealthCheck() { | |
| LOG.info("Container Health task thread took {} milliseconds to" + | ||
| " process {} existing database records.", | ||
| Time.monotonicNow() - start, existingCount); | ||
|
|
||
| checkAndProcessContainers(unhealthyContainerStateStatsMap, currentTime); | ||
| processedContainers.clear(); | ||
| } finally { | ||
| lock.writeLock().unlock(); | ||
| } | ||
| } | ||
|
|
||
| private void checkAndProcessContainers( | ||
| Map<UnHealthyContainerStates, Map<String, Long>> | ||
| unhealthyContainerStateStatsMap, long currentTime) { | ||
| ContainerID startID = ContainerID.valueOf(1); | ||
| List<ContainerInfo> containers = containerManager.getContainers(startID, | ||
| Integer.parseInt(DEFAULT_FETCH_COUNT)); | ||
| long start; | ||
sumitagrawl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| while (!containers.isEmpty()) { | ||
| start = Time.monotonicNow(); | ||
| final List<ContainerInfo> containers = containerManager.getContainers(); | ||
| containers.stream() | ||
| .filter(c -> !processedContainers.contains(c)) | ||
| .forEach(c -> processContainer(c, currentTime, | ||
|
|
@@ -142,9 +158,14 @@ public void triggerContainerHealthCheck() { | |
| " processing {} containers.", Time.monotonicNow() - start, | ||
| containers.size()); | ||
| logUnhealthyContainerStats(unhealthyContainerStateStatsMap); | ||
| processedContainers.clear(); | ||
| } finally { | ||
| lock.writeLock().unlock(); | ||
| if (containers.size() > Integer.parseInt(DEFAULT_FETCH_COUNT)) { | ||
| startID = ContainerID.valueOf( | ||
sumitagrawl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| containers.get(containers.size() - 1).getContainerID()); | ||
| containers.clear(); | ||
sumitagrawl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| containers = containerManager.getContainers(startID, | ||
| Integer.parseInt(DEFAULT_FETCH_COUNT)); | ||
| } | ||
| containers.clear(); | ||
|
||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Could we replace the usage of
Integer.parseInt(DEFAULT_FETCH_COUNT)with a named constant asDEFAULT_FETCH_COUNTis a constant.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.
Ok.