HDFS-16642. Moving the selecting inputstream from journalnode in EditLogTailer outof FSNLock (#4497)
This commit is contained in:
parent
66dec9d322
commit
8eebf40b1a
@ -328,20 +328,11 @@ public Void run() throws Exception {
|
||||
|
||||
@VisibleForTesting
|
||||
public long doTailEdits() throws IOException, InterruptedException {
|
||||
// Write lock needs to be interruptible here because the
|
||||
// transitionToActive RPC takes the write lock before calling
|
||||
// tailer.stop() -- so if we're not interruptible, it will
|
||||
// deadlock.
|
||||
namesystem.writeLockInterruptibly();
|
||||
try {
|
||||
Collection<EditLogInputStream> streams;
|
||||
FSImage image = namesystem.getFSImage();
|
||||
|
||||
long lastTxnId = image.getLastAppliedTxId();
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("lastTxnId: " + lastTxnId);
|
||||
}
|
||||
Collection<EditLogInputStream> streams;
|
||||
LOG.debug("lastTxnId: {}", lastTxnId);
|
||||
long startTime = timer.monotonicNow();
|
||||
try {
|
||||
streams = editLog.selectInputStreams(lastTxnId + 1, 0,
|
||||
@ -357,6 +348,18 @@ public long doTailEdits() throws IOException, InterruptedException {
|
||||
NameNode.getNameNodeMetrics().addEditLogFetchTime(
|
||||
timer.monotonicNow() - startTime);
|
||||
}
|
||||
// Write lock needs to be interruptible here because the
|
||||
// transitionToActive RPC takes the write lock before calling
|
||||
// tailer.stop() -- so if we're not interruptible, it will
|
||||
// deadlock.
|
||||
namesystem.writeLockInterruptibly();
|
||||
try {
|
||||
long currentLastTxnId = image.getLastAppliedTxId();
|
||||
if (lastTxnId != currentLastTxnId) {
|
||||
LOG.warn("The currentLastTxnId({}) is different from preLastTxtId({})",
|
||||
currentLastTxnId, lastTxnId);
|
||||
return 0;
|
||||
}
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("edit streams to load from: " + streams.size());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user