From d93b9d595cddd4979c0aea1259f789e7bf3a2d0e Mon Sep 17 00:00:00 2001 From: zhangduo Date: Wed, 30 Nov 2016 21:41:29 +0800 Subject: [PATCH] HBASE-17206 FSHLog may roll a new writer successfully with unflushed entries --- .../apache/hadoop/hbase/regionserver/wal/FSHLog.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index de5c588..34103dd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -849,6 +849,12 @@ public class FSHLog extends AbstractFSWAL { */ private volatile CountDownLatch safePointReleasedLatch = new CountDownLatch(1); + private void checkIfSyncFailed(SyncFuture syncFuture) throws FailedSyncBeforeLogCloseException { + if (syncFuture.isThrowable()) { + throw new FailedSyncBeforeLogCloseException(syncFuture.getThrowable()); + } + } + /** * For Thread A to call when it is ready to wait on the 'safe point' to be attained. Thread A * will be held in here until Thread B calls {@link #safePointAttained()} @@ -856,16 +862,12 @@ public class FSHLog extends AbstractFSWAL { * exception, then something is up w/ our syncing. * @return The passed syncFuture */ - SyncFuture waitSafePoint(final SyncFuture syncFuture) throws InterruptedException, + SyncFuture waitSafePoint(SyncFuture syncFuture) throws InterruptedException, FailedSyncBeforeLogCloseException { - while (true) { - if (this.safePointAttainedLatch.await(1, TimeUnit.MILLISECONDS)) { - break; - } - if (syncFuture.isThrowable()) { - throw new FailedSyncBeforeLogCloseException(syncFuture.getThrowable()); - } + while (!this.safePointAttainedLatch.await(1, TimeUnit.MILLISECONDS)) { + checkIfSyncFailed(syncFuture); } + checkIfSyncFailed(syncFuture); return syncFuture; } -- 1.9.1