diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java index b552fa277d049..0a3e61285e7d3 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java @@ -103,7 +103,7 @@ class BPServiceActor implements Runnable { volatile long lastCacheReport = 0; private final Scheduler scheduler; - private final Object sendIBRLock; + private final Object sendBRLock; private final ExecutorService ibrExecutorService; Thread bpThread; @@ -161,7 +161,7 @@ enum RunningState { } commandProcessingThread = new CommandProcessingThread(this); commandProcessingThread.start(); - sendIBRLock = new Object(); + sendBRLock = new Object(); ibrExecutorService = Executors.newSingleThreadExecutor( new ThreadFactoryBuilder().setDaemon(true) .setNameFormat("ibr-executor-%d").build()); @@ -397,10 +397,9 @@ List blockReport(long fullBrLeaseId) throws IOException { // we have a chance that we will miss the delHint information // or we will report an RBW replica after the BlockReport already reports // a FINALIZED one. - synchronized (sendIBRLock) { - ibrManager.sendIBRs(bpNamenode, bpRegistration, - bpos.getBlockPoolId(), getRpcMetricSuffix()); - } + ibrManager.sendIBRs(bpNamenode, bpRegistration, + bpos.getBlockPoolId(), getRpcMetricSuffix()); + long brCreateStartTime = monotonicNow(); Map perVolumeBlockLists = @@ -765,7 +764,9 @@ private void offerService() throws Exception { LOG.info("Forcing a full block report to " + nnAddr); } if ((fullBlockReportLeaseId != 0) || forceFullBr) { - cmds = blockReport(fullBlockReportLeaseId); + synchronized (sendBRLock) { + cmds = blockReport(fullBlockReportLeaseId); + } fullBlockReportLeaseId = 0; } commandProcessingThread.enqueue(cmds); @@ -1170,7 +1171,7 @@ public void run() { final boolean sendHeartbeat = scheduler.isHeartbeatDue(startTime); if (!dn.areIBRDisabledForTests() && (ibrManager.sendImmediately() || sendHeartbeat)) { - synchronized (sendIBRLock) { + synchronized (sendBRLock) { ibrManager.sendIBRs(bpNamenode, bpRegistration, bpos.getBlockPoolId(), getRpcMetricSuffix()); }