From a8c94f8a7cc53ca834c3ec0e0d3441ca78a8e40e Mon Sep 17 00:00:00 2001 From: Vladimir Rodionov Date: Mon, 24 Sep 2018 17:28:26 -0700 Subject: [PATCH] HBASE-21219: Hbase incremental backup fails with null pointer exception --- .../hbase/backup/impl/IncrementalBackupManager.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java index 3eebf4299c..501fa02a45 100644 --- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java +++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/IncrementalBackupManager.java @@ -296,9 +296,20 @@ public class IncrementalBackupManager extends BackupManager { currentLogFile = log.getPath().toString(); resultLogFiles.add(currentLogFile); currentLogTS = BackupUtils.getCreationTime(log.getPath()); - // newestTimestamps is up-to-date with the current list of hosts - // so newestTimestamps.get(host) will not be null. - if (currentLogTS > newestTimestamps.get(host)) { + + // If newestTimestamps.get(host) is null, means that + // either RS (host) has been restarted recently with different port number + // or RS is down (was decommisioned). In any case, we treat this + // log file as eligible for inclusion into incremental backup log list + Long ts = newestTimestamps.get(host); + if (ts == null) { + LOG.warn("ORPHAN log found: " + log + " host=" + host); + LOG.warn("Known hosts (from newestTimestamps):"); + for (String s: newestTimestamps.keySet()) { + LOG.warn(s); + } + } + if (ts == null || currentLogTS > ts) { newestLogs.add(currentLogFile); } } @@ -343,7 +354,7 @@ public class IncrementalBackupManager extends BackupManager { // Even if these logs belong to a obsolete region server, we still need // to include they to avoid loss of edits for backup. Long newTimestamp = newestTimestamps.get(host); - if (newTimestamp != null && currentLogTS > newTimestamp) { + if (newTimestamp == null || currentLogTS > newTimestamp) { newestLogs.add(currentLogFile); } } -- 2.14.3 (Apple Git-98)