[
https://issues.apache.org/jira/browse/HDFS-15796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17376568#comment-17376568
]
Stephen O'Donnell commented on HDFS-15796:
------------------------------------------
For the latest patch, why not just use `return new ArrayList<>(found.targets);`
rather than Collections.copy and another local variable? That will create a
return a new list with the contents of the original in a single line, rather
than 3 lines like here?
Also, you don't seem to have initialized targets, and I don't think
Collections.copy will work with a null target:
{code}
List<DatanodeStorageInfo> getTargets(BlockInfo block) {
synchronized (pendingReconstructions) {
+ List<DatanodeStorageInfo> targets = null;
PendingBlockInfo found = pendingReconstructions.get(block);
if (found != null) {
- return found.targets;
+ Collections.copy(targets, found.targets);
+ return targets;
}
{code}
Can you also name the patch files like HDFS-15796.001.patch. I am not sure if
the system will handle the naming format you have used correctly.
> ConcurrentModificationException error happens on NameNode occasionally
> ----------------------------------------------------------------------
>
> Key: HDFS-15796
> URL: https://issues.apache.org/jira/browse/HDFS-15796
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: hdfs
> Affects Versions: 3.1.1
> Reporter: Daniel Ma
> Priority: Critical
> Attachments: 0001-HDFS-15796.patch, 0002-HDFS-15796.patch
>
>
> ConcurrentModificationException error happens on NameNode occasionally.
>
> {code:java}
> 2021-01-23 20:21:18,107 | ERROR | RedundancyMonitor | RedundancyMonitor
> thread received Runtime exception. | BlockManager.java:4746
> java.util.ConcurrentModificationException
> at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
> at java.util.ArrayList$Itr.next(ArrayList.java:859)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.computeReconstructionWorkForBlocks(BlockManager.java:1907)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.computeBlockReconstructionWork(BlockManager.java:1859)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.computeDatanodeWork(BlockManager.java:4862)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager$RedundancyMonitor.run(BlockManager.java:4729)
> at java.lang.Thread.run(Thread.java:748)
> {code}
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]