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
|
@VisibleForTesting
|
||||||
public long doTailEdits() throws IOException, InterruptedException {
|
public long doTailEdits() throws IOException, InterruptedException {
|
||||||
// Write lock needs to be interruptible here because the
|
Collection<EditLogInputStream> streams;
|
||||||
// transitionToActive RPC takes the write lock before calling
|
|
||||||
// tailer.stop() -- so if we're not interruptible, it will
|
|
||||||
// deadlock.
|
|
||||||
namesystem.writeLockInterruptibly();
|
|
||||||
try {
|
|
||||||
FSImage image = namesystem.getFSImage();
|
FSImage image = namesystem.getFSImage();
|
||||||
|
|
||||||
long lastTxnId = image.getLastAppliedTxId();
|
long lastTxnId = image.getLastAppliedTxId();
|
||||||
|
LOG.debug("lastTxnId: {}", lastTxnId);
|
||||||
if (LOG.isDebugEnabled()) {
|
|
||||||
LOG.debug("lastTxnId: " + lastTxnId);
|
|
||||||
}
|
|
||||||
Collection<EditLogInputStream> streams;
|
|
||||||
long startTime = timer.monotonicNow();
|
long startTime = timer.monotonicNow();
|
||||||
try {
|
try {
|
||||||
streams = editLog.selectInputStreams(lastTxnId + 1, 0,
|
streams = editLog.selectInputStreams(lastTxnId + 1, 0,
|
||||||
@ -357,6 +348,18 @@ public long doTailEdits() throws IOException, InterruptedException {
|
|||||||
NameNode.getNameNodeMetrics().addEditLogFetchTime(
|
NameNode.getNameNodeMetrics().addEditLogFetchTime(
|
||||||
timer.monotonicNow() - startTime);
|
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()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("edit streams to load from: " + streams.size());
|
LOG.debug("edit streams to load from: " + streams.size());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user