HBASE-21475 Put mutation (having TTL set) added via co-processor is retrieved even after TTL expires

Signed-off-by: Andrew Purtell <apurtell@apache.org>

Conflicts:
	hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
	hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverForAddingMutationsFromCoprocessors.java

Amending-Author: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Nihal Jain 2018-11-13 23:25:13 +05:30 committed by Andrew Purtell
parent 20759a3c7e
commit c1c2bc2f0a
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
2 changed files with 29 additions and 0 deletions

View File

@ -3417,6 +3417,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
for (int j = 0; j < cpMutations.length; j++) {
Mutation cpMutation = cpMutations[j];
Map<byte[], List<Cell>> cpFamilyMap = cpMutation.getFamilyCellMap();
rewriteCellTags(cpFamilyMap, mutation);
checkAndPrepareMutation(cpMutation, isInReplay, cpFamilyMap, now);
// Acquire row locks. If not, the whole batch will fail.

View File

@ -194,6 +194,34 @@ public class TestRegionObserverForAddingMutationsFromCoprocessors {
}
}
@Test
public void testPutWithTTL() throws Exception {
createTable(TestPutWithTTLCoprocessor.class.getName());
try (Table t = util.getConnection().getTable(tableName)) {
t.put(new Put(row1).addColumn(test, dummy, dummy).setTTL(3000));
assertRowCount(t, 2);
// wait long enough for the TTL to expire
Thread.sleep(5000);
assertRowCount(t, 0);
}
}
public static class TestPutWithTTLCoprocessor extends BaseRegionObserver {
@Override
public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
Mutation mut = miniBatchOp.getOperation(0);
List<Cell> cells = mut.getFamilyCellMap().get(test);
Put[] puts = new Put[] {
new Put(Bytes.toBytes("cpPut")).addColumn(test, dummy, cells.get(0).getTimestamp(),
Bytes.toBytes("cpdummy")).setTTL(mut.getTTL())
};
LOG.info("Putting:" + Arrays.toString(puts));
miniBatchOp.addOperationsFromCP(0, puts);
}
}
public static class TestMultiMutationCoprocessor extends BaseRegionObserver {
@Override
public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,