From d493073e548f316567dc190b03e2b4a1a6986d89 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Fri, 30 Oct 2009 22:23:08 +0000 Subject: [PATCH] HBASE-1682 IndexedRegion does not properly handle deletes git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@831473 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../tableindexed/IndexedRegion.java | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) 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) {