phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject [31/46] phoenix git commit: PHOENIX-3759 Dropping a local index causes NPE
Date Wed, 10 May 2017 18:04:30 GMT
PHOENIX-3759 Dropping a local index causes NPE


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/92b951e5
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/92b951e5
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/92b951e5

Branch: refs/heads/omid
Commit: 92b951e5387768e084ed09729884a59160cd81d3
Parents: 90e32c0
Author: Ankit Singhal <ankitsinghal59@gmail.com>
Authored: Fri Apr 21 11:48:54 2017 +0530
Committer: Ankit Singhal <ankitsinghal59@gmail.com>
Committed: Fri Apr 21 11:48:54 2017 +0530

----------------------------------------------------------------------
 .../apache/phoenix/end2end/index/LocalIndexIT.java   | 15 ++++++++++++---
 .../java/org/apache/phoenix/util/RepairUtil.java     | 11 +++++++----
 2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/92b951e5/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
index 8d3316b..ea4780b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
@@ -599,21 +599,30 @@ public class LocalIndexIT extends BaseLocalIndexIT {
             admin.disableTable(tableName);
             copyLocalIndexHFiles(config, tableRegions.get(0), tableRegions.get(1), false);
             copyLocalIndexHFiles(config, tableRegions.get(3), tableRegions.get(0), false);
-
             admin.enableTable(tableName);
 
             int count=getCount(conn, tableName, "L#0");
             assertTrue(count > 14);
-            admin.majorCompact(tableName);
+            admin.majorCompact(TableName.valueOf(tableName));
             int tryCount = 5;// need to wait for rebuilding of corrupted local index region
             while (tryCount-- > 0 && count != 14) {
-                Thread.sleep(30000);
+                Thread.sleep(15000);
                 count = getCount(conn, tableName, "L#0");
             }
             assertEquals(14, count);
             rs = statement.executeQuery("SELECT COUNT(*) FROM " + indexName1);
             assertTrue(rs.next());
             assertEquals(7, rs.getLong(1));
+            statement.execute("DROP INDEX " + indexName1 + " ON " + tableName);
+            admin.majorCompact(TableName.valueOf(tableName));
+            statement.execute("DROP INDEX " + indexName + " ON " + tableName);
+            admin.majorCompact(TableName.valueOf(tableName));
+            Thread.sleep(15000);
+            admin.majorCompact(TableName.valueOf(tableName));
+            Thread.sleep(15000);
+            rs = statement.executeQuery("SELECT COUNT(*) FROM " + tableName);
+            assertTrue(rs.next());
+            
         }
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/92b951e5/phoenix-core/src/main/java/org/apache/phoenix/util/RepairUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/RepairUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/RepairUtil.java
index b9b7526..ea14715 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/RepairUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/RepairUtil.java
@@ -29,10 +29,13 @@ public class RepairUtil {
         byte[] endKey = environment.getRegion().getRegionInfo().getEndKey();
         byte[] indexKeyEmbedded = startKey.length == 0 ? new byte[endKey.length] : startKey;
         for (StoreFile file : store.getStorefiles()) {
-            byte[] fileFirstRowKey = KeyValue.createKeyValueFromKey(file.getReader().getFirstKey()).getRow();;
-            if ((fileFirstRowKey != null && Bytes.compareTo(file.getReader().getFirstKey(),
0, indexKeyEmbedded.length,
-                    indexKeyEmbedded, 0, indexKeyEmbedded.length) != 0)
-                    /*|| (endKey.length > 0 && Bytes.compareTo(file.getLastKey(),
endKey) < 0)*/) { return false; }
+            if (file.getReader() != null && file.getReader().getFirstKey() != null)
{
+                byte[] fileFirstRowKey = KeyValue.createKeyValueFromKey(file.getReader().getFirstKey()).getRow();
+                ;
+                if ((fileFirstRowKey != null && Bytes.compareTo(file.getReader().getFirstKey(),
0,
+                        indexKeyEmbedded.length, indexKeyEmbedded, 0, indexKeyEmbedded.length)
!= 0)
+                /* || (endKey.length > 0 && Bytes.compareTo(file.getLastKey(),
endKey) < 0) */) { return false; }
+            }
         }
         return true;
     }


Mime
View raw message