diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java index 3bc6a0f4c61..e42979efe36 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java @@ -158,7 +158,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner this.scan = scan; this.columns = columns; this.now = EnvironmentEdgeManager.currentTime(); - this.oldestUnexpiredTS = now - scanInfo.getTtl(); + this.oldestUnexpiredTS = scan.isRaw() ? 0L : now - scanInfo.getTtl(); this.minVersions = scanInfo.getMinVersions(); // We look up row-column Bloom filters for multi-column queries as part of diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java index e5c19ac8721..1b18ee2fa1f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java @@ -16,9 +16,12 @@ */ package org.apache.hadoop.hbase.client; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -30,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; @@ -795,4 +799,24 @@ public class TestScannersFromClientSide { assertEquals(expKvList.size(), result.size()); } + + @Test + public void testReadExpiredDataForRawScan() throws IOException { + TableName tableName = TableName.valueOf(name.getMethodName()); + long ts = System.currentTimeMillis() - 10000; + byte[] value = Bytes.toBytes("expired"); + try (Table table = TEST_UTIL.createTable(tableName, FAMILY)) { + table.put(new Put(ROW).addColumn(FAMILY, QUALIFIER, ts, value)); + assertArrayEquals(value, table.get(new Get(ROW)).getValue(FAMILY, QUALIFIER)); + TEST_UTIL.getAdmin().modifyColumnFamily(tableName, + new HColumnDescriptor(FAMILY).setTimeToLive(5)); + try (ResultScanner scanner = table.getScanner(FAMILY)) { + assertNull(scanner.next()); + } + try (ResultScanner scanner = table.getScanner(new Scan().setRaw(true))) { + assertArrayEquals(value, scanner.next().getValue(FAMILY, QUALIFIER)); + assertNull(scanner.next()); + } + } + } }