diff --git a/CHANGES.txt b/CHANGES.txt index 657c28f26ab..e53da0c9111 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -84,6 +84,8 @@ Release 0.21.0 - Unreleased HBASE-1927 Scanners not closed properly in certain circumstances HBASE-1934 NullPointerException in ClientScanner (Andrew Purtell via Stack) HBASE-1946 Unhandled exception at regionserver (Dmitriy Lyfar via Stack) + HBASE-1682 IndexedRegion does not properly handle deletes + (Andrew McCall via Clint Morgan and Stack) IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java index f41c71616c1..4c1ab700da2 100644 --- a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java +++ b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java @@ -229,7 +229,7 @@ class IndexedRegion extends TransactionalRegion { @Override public void delete(Delete delete, final Integer lockid, boolean writeToWAL) throws IOException { - + // First remove the existing indexes. if (!getIndexes().isEmpty()) { // Need all columns NavigableSet neededColumns = getColumnsForIndexes(getIndexes()); @@ -251,13 +251,17 @@ class IndexedRegion extends TransactionalRegion { for (IndexSpecification indexSpec : getIndexes()) { removeOldIndexEntry(indexSpec, delete.getRow(), oldColumnValues); } + } + + super.delete(delete, lockid, writeToWAL); - // Handle if there is still a version visible. - if (delete.getTimeStamp() != HConstants.LATEST_TIMESTAMP) { - get.setTimeRange(1, delete.getTimeStamp()); - oldRow = super.get(get, lockid); - SortedMap currentColumnValues = convertToValueMap(oldRow); - + if (!getIndexes().isEmpty()) { + Get get = new Get(delete.getRow()); + + // Rebuild index if there is still a version visible. + Result currentRow = super.get(get, lockid); + if (!currentRow.isEmpty()) { + SortedMap currentColumnValues = convertToValueMap(currentRow); for (IndexSpecification indexSpec : getIndexes()) { if (IndexMaintenanceUtils.doesApplyToIndex(indexSpec, currentColumnValues)) { updateIndex(indexSpec, delete.getRow(), currentColumnValues); @@ -265,7 +269,7 @@ class IndexedRegion extends TransactionalRegion { } } } - super.delete(delete, lockid, writeToWAL); + } private SortedMap convertToValueMap(Result result) {