From 8e84390b376f02724da550241d3e7289cfc5514c Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Fri, 16 Mar 2012 16:39:44 +0000 Subject: [PATCH] HBASE-5568 Multi concurrent flushcache() for one region could cause data loss (Chunhui) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1301639 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/regionserver/HRegion.java | 28 +++++++++---------- .../hadoop/hbase/regionserver/TestStore.java | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 859d3c2971f..24b23e49e8f 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -1318,22 +1318,22 @@ public class HRegion implements HeapSize { // , Writable{ status.setStatus("Running coprocessor pre-flush hooks"); coprocessorHost.preFlush(); } - try { - synchronized (writestate) { - if (!writestate.flushing && writestate.writesEnabled) { - this.writestate.flushing = true; - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("NOT flushing memstore for region " + this + - ", flushing=" + - writestate.flushing + ", writesEnabled=" + - writestate.writesEnabled); - } - status.abort("Not flushing since " + - (writestate.flushing ? "already flushing" : "writes not enabled")); - return false; + synchronized (writestate) { + if (!writestate.flushing && writestate.writesEnabled) { + this.writestate.flushing = true; + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("NOT flushing memstore for region " + this + + ", flushing=" + writestate.flushing + ", writesEnabled=" + + writestate.writesEnabled); } + status.abort("Not flushing since " + + (writestate.flushing ? "already flushing" + : "writes not enabled")); + return false; } + } + try { boolean result = internalFlushcache(status); if (coprocessorHost != null) { diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java b/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java index bd7204c968e..121d2778930 100644 --- a/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java @@ -152,7 +152,7 @@ public class TestStore extends TestCase { public void testDeleteExpiredStoreFiles() throws Exception { int storeFileNum = 4; - int ttl = 1; + int ttl = 4; Configuration conf = HBaseConfiguration.create(); // Enable the expired store file deletion