hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1542569 - in /hbase/branches/0.96/hbase-server/src: main/java/org/apache/hadoop/hbase/regionserver/ main/java/org/apache/hadoop/hbase/util/ test/java/org/apache/hadoop/hbase/regionserver/
Date Sat, 16 Nov 2013 21:16:34 GMT
Author: tedyu
Date: Sat Nov 16 21:16:33 2013
New Revision: 1542569

URL: http://svn.apache.org/r1542569
Log:
HBASE-9949 Revert due to TestHRegion failure


Removed:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/InjectionEvent.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/InjectionHandler.java
Modified:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
    hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreScanner.java

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java?rev=1542569&r1=1542568&r2=1542569&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java
Sat Nov 16 21:16:33 2013
@@ -65,7 +65,6 @@ import org.apache.hadoop.hbase.io.hfile.
 import org.apache.hadoop.hbase.monitoring.MonitoredTask;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.generated.WALProtos.CompactionDescriptor;
-import org.apache.hadoop.hbase.regionserver.StoreScanner.StoreScannerCompactionRace;
 import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext;
 import org.apache.hadoop.hbase.regionserver.compactions.CompactionProgress;
 import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
@@ -75,8 +74,6 @@ import org.apache.hadoop.hbase.util.Byte
 import org.apache.hadoop.hbase.util.ChecksumType;
 import org.apache.hadoop.hbase.util.ClassSize;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.apache.hadoop.hbase.util.InjectionEvent;
-import org.apache.hadoop.hbase.util.InjectionHandler;
 import org.apache.hadoop.util.StringUtils;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -1382,8 +1379,6 @@ public class HStore implements Store {
       // scenario that could have happened if continue to hold the lock.
       notifyChangedReadersObservers();
       // At this point the store will use new files for all scanners.
-      InjectionHandler.processEvent(InjectionEvent.STORESCANNER_COMPACTION_RACE, new Object[]
{
-          StoreScannerCompactionRace.BEFORE_SEEK.ordinal()});
 
       // let the archive util decide if we should archive or delete the files
       LOG.debug("Removing store files after compaction...");

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java?rev=1542569&r1=1542568&r2=1542569&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
Sat Nov 16 21:16:33 2013
@@ -37,11 +37,10 @@ import org.apache.hadoop.hbase.KeyValueU
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.regionserver.ScanInfo;
 import org.apache.hadoop.hbase.regionserver.handler.ParallelSeekHandler;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.apache.hadoop.hbase.util.InjectionEvent;
-import org.apache.hadoop.hbase.util.InjectionHandler;
 
 /**
  * Scanner scans both the memstore and the Store. Coalesce KeyValue stream
@@ -97,13 +96,6 @@ public class StoreScanner extends NonLaz
   // A flag whether use pread for scan
   private boolean scanUsePread = false;
 
-  // used by the injection framework to test race between StoreScanner construction and compaction
-  enum StoreScannerCompactionRace {
-    BEFORE_SEEK,
-    AFTER_SEEK,
-    COMPACT_COMPLETE
-  }
-  
   /** An internal constructor. */
   protected StoreScanner(Store store, boolean cacheBlocks, Scan scan,
       final NavigableSet<byte[]> columns, long ttl, int minVersions) {
@@ -157,8 +149,6 @@ public class StoreScanner extends NonLaz
         ScanType.USER_SCAN, Long.MAX_VALUE, HConstants.LATEST_TIMESTAMP,
         oldestUnexpiredTS);
 
-    this.store.addChangedReaderObserver(this);
-
     // Pass columns to try to filter out unnecessary StoreFiles.
     List<KeyValueScanner> scanners = getScannersNoCompaction();
 
@@ -166,8 +156,6 @@ public class StoreScanner extends NonLaz
     // key does not exist, then to the start of the next matching Row).
     // Always check bloom filter to optimize the top row seek for delete
     // family marker.
-    InjectionHandler.processEvent(InjectionEvent.STORESCANNER_COMPACTION_RACE, new Object[]
{
-        StoreScannerCompactionRace.BEFORE_SEEK.ordinal()});
     if (explicitColumnQuery && lazySeekEnabledGlobally) {
       for (KeyValueScanner scanner : scanners) {
         scanner.requestSeek(matcher.getStartKey(), false, true);
@@ -190,8 +178,8 @@ public class StoreScanner extends NonLaz
 
     // Combine all seeked scanners with a heap
     heap = new KeyValueHeap(scanners, store.getComparator());
-    InjectionHandler.processEvent(InjectionEvent.STORESCANNER_COMPACTION_RACE, new Object[]
{
-        StoreScannerCompactionRace.AFTER_SEEK.ordinal()});
+
+    this.store.addChangedReaderObserver(this);
   }
 
   /**
@@ -241,13 +229,9 @@ public class StoreScanner extends NonLaz
           earliestPutTs, oldestUnexpiredTS, dropDeletesFromRow, dropDeletesToRow);
     }
 
-    this.store.addChangedReaderObserver(this);
-
     // Filter the list of scanners using Bloom filters, time range, TTL, etc.
     scanners = selectScannersFrom(scanners);
 
-    InjectionHandler.processEvent(InjectionEvent.STORESCANNER_COMPACTION_RACE, new Object[]
{
-        StoreScannerCompactionRace.BEFORE_SEEK.ordinal()});
     // Seek all scanners to the initial key
     if (!isParallelSeekEnabled) {
       for (KeyValueScanner scanner : scanners) {
@@ -259,8 +243,6 @@ public class StoreScanner extends NonLaz
 
     // Combine all seeked scanners with a heap
     heap = new KeyValueHeap(scanners, store.getComparator());
-    InjectionHandler.processEvent(InjectionEvent.STORESCANNER_COMPACTION_RACE, new Object[]
{
-        StoreScannerCompactionRace.AFTER_SEEK.ordinal()});
   }
 
   /** Constructor for testing. */
@@ -281,10 +263,6 @@ public class StoreScanner extends NonLaz
     this.matcher = new ScanQueryMatcher(scan, scanInfo, columns, scanType,
         Long.MAX_VALUE, earliestPutTs, oldestUnexpiredTS);
 
-    // In unit tests, the store could be null
-    if (this.store != null) {
-      this.store.addChangedReaderObserver(this);
-    }
     // Seek all scanners to the initial key
     if (!isParallelSeekEnabled) {
       for (KeyValueScanner scanner : scanners) {

Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreScanner.java?rev=1542569&r1=1542568&r2=1542569&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreScanner.java
(original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreScanner.java
Sat Nov 16 21:16:33 2013
@@ -27,28 +27,18 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.NavigableSet;
 import java.util.TreeSet;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
 
 import junit.framework.TestCase;
 
 import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.KeyValueTestUtil;
 import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.regionserver.StoreScanner.StoreScannerCompactionRace;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdge;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
-import org.apache.hadoop.hbase.util.InjectionEvent;
-import org.apache.hadoop.hbase.util.InjectionHandler;
-import org.apache.hadoop.hbase.util.Threads;
 import org.junit.experimental.categories.Category;
 
 // Can't be small as it plays with EnvironmentEdgeManager
@@ -511,110 +501,6 @@ public class TestStoreScanner extends Te
     assertEquals(false, scanner.next(results));
   }
 
-  private class StoreScannerCompactionRaceCondition extends InjectionHandler {
-    final Store store;
-    Boolean beforeSeek = false;
-    Boolean afterSeek = false;
-    Boolean compactionComplete = false;
-    final int waitTime;
-    boolean doneSeeking = false;
-    public Future<Void> f;
-    StoreScannerCompactionRaceCondition(Store s, int waitTime) {
-      this.store = s;
-      this.waitTime = waitTime;
-    }
-
-    protected void _processEvent(InjectionEvent event, Object... args) {
-      if (event == InjectionEvent.STORESCANNER_COMPACTION_RACE) {
-        // To prevent other scanners which are not supposed to be tested from taking this
code path.
-        if ((args instanceof Object[]) && (args.length == 1)
-            && (args[0] instanceof Integer)) {
-          StoreScannerCompactionRace sscr = StoreScannerCompactionRace.values()[(Integer)args[0]];
-          switch (sscr) {
-          case BEFORE_SEEK :
-            // Inside StoreScanner ctor before seek.
-            synchronized (beforeSeek) {
-              if (!beforeSeek) {
-                beforeSeek = true;
-                f = Executors.newSingleThreadExecutor().submit(new Callable<Void>()
{
-                  @Override
-                  public Void call() throws Exception {
-                    StoreScanner.enableLazySeekGlobally(false);
-                    ((HStore)store).compactRecentForTestingAssumingDefaultPolicy(
-                      store.getStorefiles().size() / 2);
-                    StoreScanner.enableLazySeekGlobally(true);
-                    return null;
-                  }
-                });
-                Threads.sleep(waitTime);
-              }
-            }
-            break;
-          case AFTER_SEEK:
-            // Inside StoreScanner ctor after seek.
-            synchronized (afterSeek) {
-              if (!afterSeek) {
-                afterSeek = true;
-                this.doneSeeking = true;
-              }
-            }
-            break;
-          case COMPACT_COMPLETE:
-            // Inside HStore.completeCompaction
-            synchronized (compactionComplete) {
-              if (!compactionComplete) {
-                compactionComplete = true;
-                assertTrue(doneSeeking);
-              }
-            }
-            break;
-          }
-        }
-      }
-    }
-  }
-
-  /*
-   *  Verifies that there is no race condition between StoreScanner construction and compaction.
-   *  This is done through 3 injection points:
-   *  1. before seek operation in StoreScanner ctor
-   *  2. after seek operation in StoreScanner ctor
-   *  3. after compaction completion
-   */
-  public void testCompactionRaceCondition() throws Exception {
-    HBaseTestingUtility util = new HBaseTestingUtility();
-    util.startMiniCluster(1);
-    byte[] t = Bytes.toBytes("tbl"), cf = Bytes.toBytes("cf");
-    HTable table = util.createTable(t, cf);
-    util.loadTable(table, cf);
-    util.flush();
-    util.loadTable(table, cf);
-    util.flush();
-    List<HRegion> regions = util.getHBaseCluster().getRegions(t);
-    assertTrue(regions.size() == 1);
-    HRegion r = regions.get(0);
-    Store s = r.getStore(cf);
-
-    // Setup the injection handler.
-    StoreScannerCompactionRaceCondition ih =
-        new StoreScannerCompactionRaceCondition(s, 5);
-    InjectionHandler.set(ih);
-
-    // Create a StoreScanner
-    TreeSet<byte[]> set = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
-    set.add(cf);
-    Scan scanSpec = new Scan();
-    scanSpec.setStartRow(Bytes.toBytes("hjfsd"));
-    scanSpec.setStartRow(Bytes.toBytes("zjfsd"));
-    KeyValueScanner scanner = s.getScanner(scanSpec, set);
-    ih.f.get();
-
-    // Clear injection handling and shutdown the minicluster.
-    InjectionHandler.clear();
-    scanner.close();
-    util.shutdownMiniCluster();
-  }
-
   public void testDeleteMarkerLongevity() throws Exception {
     try {
       final long now = System.currentTimeMillis();



Mime
View raw message