diff --git a/CHANGES.txt b/CHANGES.txt index f9410d0ce8d..31a95ea0199 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,7 @@ Release 0.21.0 - Unreleased HBASE-1792 [Regression] Cannot save timestamp in the future HBASE-1793 [Regression] HTable.get/getRow with a ts is broken HBASE-1698 Review documentation for o.a.h.h.mapreduce + HBASE-1798 [Regression] Unable to delete a row in the future IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/src/java/org/apache/hadoop/hbase/KeyValue.java b/src/java/org/apache/hadoop/hbase/KeyValue.java index 36d553efeff..3e3abf4bc6b 100644 --- a/src/java/org/apache/hadoop/hbase/KeyValue.java +++ b/src/java/org/apache/hadoop/hbase/KeyValue.java @@ -819,9 +819,8 @@ public class KeyValue implements Writable, HeapSize { } public boolean updateLatestStamp(final byte [] now) { - int tsOffset = getTimestampOffset(); - if(Bytes.compareTo(now, 0, Bytes.SIZEOF_LONG, - this.bytes, tsOffset, Bytes.SIZEOF_LONG) < 0) { + if(this.isLatestTimestamp()) { + int tsOffset = getTimestampOffset(); System.arraycopy(now, 0, this.bytes, tsOffset, Bytes.SIZEOF_LONG); return true; } diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java index d36546b5633..5d70811adc2 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -1108,7 +1108,8 @@ public class HRegion implements HConstants, HeapSize { // , Writable{ //Check to see if this is a deleteRow insert if(delete.getFamilyMap().isEmpty()){ for(byte [] family : regionInfo.getTableDesc().getFamiliesKeys()){ - delete.deleteFamily(family); + // Don't eat the timestamp + delete.deleteFamily(family, delete.getTimeStamp()); } } else { for(byte [] family : delete.getFamilyMap().keySet()) { diff --git a/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java index 2534e1eac54..e2d940ffc13 100644 --- a/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java +++ b/src/test/org/apache/hadoop/hbase/regionserver/TestHRegion.java @@ -292,6 +292,41 @@ public class TestHRegion extends HBaseTestCase { result = region.get(get, null); assertEquals(1, result.size()); } + + public void testDeleteRowWithFutureTs() throws IOException { + byte [] tableName = Bytes.toBytes("testtable"); + byte [] fam = Bytes.toBytes("info"); + byte [][] families = {fam}; + String method = this.getName(); + initHRegion(tableName, method, families); + + byte [] row = Bytes.toBytes("table_name"); + // column names + byte [] serverinfo = Bytes.toBytes("serverinfo"); + + // add data in the far future + Put put = new Put(row); + put.add(fam, serverinfo, HConstants.LATEST_TIMESTAMP-5,Bytes.toBytes("value")); + region.put(put); + + // now delete something in the present + Delete delete = new Delete(row); + region.delete(delete, null, true); + + // make sure we still see our data + Get get = new Get(row).addColumn(fam, serverinfo); + Result result = region.get(get, null); + assertEquals(1, result.size()); + + // delete the future row + delete = new Delete(row,HConstants.LATEST_TIMESTAMP-3,null); + region.delete(delete, null, true); + + // make sure it is gone + get = new Get(row).addColumn(fam, serverinfo); + result = region.get(get, null); + assertEquals(0, result.size()); + } public void testScanner_DeleteOneFamilyNotAnother() throws IOException { byte [] tableName = Bytes.toBytes("test_table");