Skip to content

Commit

Permalink
fix mis-order of ibr and fbr.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgh committed Nov 2, 2023
1 parent 2b1378c commit 2508505
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -397,10 +397,9 @@ List<DatanodeCommand> 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<DatanodeStorage, BlockListAsLongs> perVolumeBlockLists =
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 2508505

Please sign in to comment.