diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java index f724a3e5bfa..0d2427a55e6 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/store/wal/WALProcedureStore.java @@ -111,6 +111,7 @@ public class WALProcedureStore extends ProcedureStoreBase { private final FileSystem fs; private final Path logDir; + private AtomicBoolean loading = new AtomicBoolean(true); private AtomicBoolean inSync = new AtomicBoolean(false); private AtomicReference syncException = new AtomicReference<>(); private LinkedTransferQueue slotsCache = null; @@ -276,6 +277,7 @@ public class WALProcedureStore extends ProcedureStoreBase { LOG.debug("No state logs to replay."); } loader.setMaxProcId(0); + loading.set(false); return; } @@ -320,6 +322,7 @@ public class WALProcedureStore extends ProcedureStoreBase { removeLogFile(log); } } + loading.set(false); } } @@ -528,7 +531,9 @@ public class WALProcedureStore extends ProcedureStoreBase { try { // Wait until new data is available if (slotIndex == 0) { - removeInactiveLogs(); + if (!loading.get()) { + removeInactiveLogs(); + } if (LOG.isTraceEnabled()) { float rollTsSec = getMillisFromLastRoll() / 1000.0f; diff --git a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java index 6e69ca157e5..b5747c8aa08 100644 --- a/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java +++ b/hbase-procedure/src/test/java/org/apache/hadoop/hbase/procedure2/store/wal/TestWALProcedureStore.java @@ -383,6 +383,12 @@ public class TestWALProcedureStore { procStore.start(NTHREAD); procStore.recoverLease(); + LoadCounter loader = new LoadCounter(); + procStore.load(loader); + assertEquals(0, loader.getMaxProcId()); + assertEquals(0, loader.getLoadedCount()); + assertEquals(0, loader.getCorruptedCount()); + final long LAST_PROC_ID = 9999; final Thread[] thread = new Thread[NTHREAD]; final AtomicLong procCounter = new AtomicLong((long)Math.round(Math.random() * 100));