diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 0f7bd9ff784..b9218b64364 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -3417,6 +3417,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi for (int j = 0; j < cpMutations.length; j++) { Mutation cpMutation = cpMutations[j]; Map> cpFamilyMap = cpMutation.getFamilyCellMap(); + rewriteCellTags(cpFamilyMap, mutation); checkAndPrepareMutation(cpMutation, isInReplay, cpFamilyMap, now); // Acquire row locks. If not, the whole batch will fail. diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverForAddingMutationsFromCoprocessors.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverForAddingMutationsFromCoprocessors.java index 3d34503c796..0ea78e36e39 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverForAddingMutationsFromCoprocessors.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverForAddingMutationsFromCoprocessors.java @@ -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 c, + MiniBatchOperationInProgress miniBatchOp) throws IOException { + Mutation mut = miniBatchOp.getOperation(0); + List 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 c,