[ 
https://issues.apache.org/jira/browse/HBASE-11788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14111204#comment-14111204
 ] 

Cristian Armaselu commented on HBASE-11788:
-------------------------------------------

This doesn't seem to work. I got a nice stack overflow when region server 
started

Snipped of code executed:
public class EmptyValueCheckObserver extends BaseRegionObserver {
...
    @Override
    public void prePut(ObserverContext<RegionCoprocessorEnvironment> e,
            Put put, WALEdit edit, Durability durability) throws IOException {
...
byte[] rowKey = put.getRow();
        Delete delete = new Delete(rowKey);
        Put overWrittenPut = new Put(rowKey);
        RowMutations rowMutations = new RowMutations(rowKey);
        rowMutations.add(delete);
        rowMutations.add(overWrittenPut);
...
//iterate over method parameter Put/KVs and do one of the below based on the 
presence or not of a value:
rowMutations.add(delete.addDeleteMarker(keyValue));
overWrittenPut.add(family, keyValue.getQualifier(), keyValue.getValue());
...
        HRegion region = e.getEnvironment().getRegion();
        e.bypass();
        region.mutateRow(rowMutations);

Error:
...
        at 
com.epsilon.cds.hbase.observer.EmptyValueCheckObserver.prePut(EmptyValueCheckObserver.java:108)
        at 
org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.prePut(RegionCoprocessorHost.java:900)
        at 
org.apache.hadoop.hbase.regionserver.MultiRowMutationProcessor.preProcess(MultiRowMutationProcessor.java:108)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.processRowsWithLocks(HRegion.java:4663)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.mutateRowsWithLocks(HRegion.java:4628)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.mutateRow(HRegion.java:4610)
        at 
com.epsilon.cds.hbase.observer.EmptyValueCheckObserver.prePut(EmptyValueCheckObserver.java:108)
        at 
org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.prePut(RegionCoprocessorHost.java:900)
        at 
org.apache.hadoop.hbase.regionserver.MultiRowMutationProcessor.preProcess(MultiRowMutationProcessor.java:108)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.processRowsWithLocks(HRegion.java:4663)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.mutateRowsWithLocks(HRegion.java:4628)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.mutateRow(HRegion.java:4610)
        at 
com.epsilon.cds.hbase.observer.EmptyValueCheckObserver.prePut(EmptyValueCheckObserver.java:108)
        at 
org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.prePut(RegionCoprocessorHost.java:900)
        at 
org.apache.hadoop.hbase.regionserver.MultiRowMutationProcessor.preProcess(MultiRowMutationProcessor.java:108)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.processRowsWithLocks(HRegion.java:4663)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.mutateRowsWithLocks(HRegion.java:4628)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.mutateRow(HRegion.java:4610)
        at 
com.epsilon.cds.hbase.observer.EmptyValueCheckObserver.prePut(EmptyValueCheckObserver.java:108)
        at 
org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.prePut(RegionCoprocessorHost.java:900)
        at 
org.apache.hadoop.hbase.regionserver.MultiRowMutationProcessor.preProcess(MultiRowMutationProcessor.java:108)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.processRowsWithLocks(HRegion.java:4663)
        at 
org.apache.hadoop.hbase.regionserver.HRegion.mutateRowsWithLocks(HRegion.java:4628)
: 1 time,
        at 
org.apache.hadoop.hbase.client.AsyncProcess$BatchErrors.makeException(AsyncProcess.java:187)
        at 
org.apache.hadoop.hbase.client.AsyncProcess$BatchErrors.access$500(AsyncProcess.java:171)
        at 
org.apache.hadoop.hbase.client.AsyncProcess.getErrors(AsyncProcess.java:882)
        at 
org.apache.hadoop.hbase.client.HTable.backgroundFlushCommits(HTable.java:940)
        at org.apache.hadoop.hbase.client.HTable.flushCommits(HTable.java:1197)
        at org.apache.hadoop.hbase.client.HTable.put(HTable.java:866)
        at org.apache.hadoop.hbase.catalog.MetaEditor.put(MetaEditor.java:126)
        at 
org.apache.hadoop.hbase.catalog.MetaEditor.putToCatalogTable(MetaEditor.java:116)
        at 
org.apache.hadoop.hbase.catalog.MetaEditor.updateLocation(MetaEditor.java:463)
        at 
org.apache.hadoop.hbase.catalog.MetaEditor.updateRegionLocation(MetaEditor.java:442)
        at 
org.apache.hadoop.hbase.regionserver.HRegionServer.postOpenDeployTasks(HRegionServer.java:1710)
        at 
org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler$PostOpenDeployTasksThread.run(OpenRegionHandler.java:335)




> hbase is not deleting the cell when a Put with a KeyValue, 
> KeyValue.Type.Delete is submitted
> --------------------------------------------------------------------------------------------
>
>                 Key: HBASE-11788
>                 URL: https://issues.apache.org/jira/browse/HBASE-11788
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 0.99.0, 0.96.1.1, 0.98.5, 2.0.0
>         Environment: Cloudera CDH 5.1.x
>            Reporter: Cristian Armaselu
>            Assignee: Srikanth Srungarapu
>         Attachments: TestPutWithDelete.java
>
>
> Code executed:
> {code}
>     @Test
>     public void testHbasePutDeleteCell() throws Exception {
>         TableName tableName = TableName.valueOf("my_test");
>         Configuration configuration = HBaseConfiguration.create();
>         HTableInterface table = new HTable(configuration, tableName);
>         final String rowKey = "12345";
>         final byte[] familly = Bytes.toBytes("default");
>         // put one row
>         Put put = new Put(Bytes.toBytes(rowKey));
>         put.add(familly, Bytes.toBytes("A"), Bytes.toBytes("a"));
>         put.add(familly, Bytes.toBytes("B"), Bytes.toBytes("b"));
>         put.add(familly, Bytes.toBytes("C"), Bytes.toBytes("c"));
>         table.put(put);
>         // get row back and assert the values
>         Get get = new Get(Bytes.toBytes(rowKey));
>         Result result = table.get(get);
>         Assert.isTrue(Bytes.toString(result.getValue(familly, 
> Bytes.toBytes("A"))).equals("a"), "Column A value should be a");
>         Assert.isTrue(Bytes.toString(result.getValue(familly, 
> Bytes.toBytes("B"))).equals("b"), "Column B value should be b");
>         Assert.isTrue(Bytes.toString(result.getValue(familly, 
> Bytes.toBytes("C"))).equals("c"), "Column C value should be c");
>         // put the same row again with C column deleted
>         put = new Put(Bytes.toBytes(rowKey));
>         put.add(familly, Bytes.toBytes("A"), Bytes.toBytes("a"));
>         put.add(familly, Bytes.toBytes("B"), Bytes.toBytes("b"));
>         put.add(new KeyValue(Bytes.toBytes(rowKey), familly, 
> Bytes.toBytes("C"), HConstants.LATEST_TIMESTAMP, KeyValue.Type.DeleteColumn));
>         table.put(put);
>         // get row back and assert the values
>         get = new Get(Bytes.toBytes(rowKey));
>         result = table.get(get);
>         Assert.isTrue(Bytes.toString(result.getValue(familly, 
> Bytes.toBytes("A"))).equals("a"), "Column A value should be a");
>         Assert.isTrue(Bytes.toString(result.getValue(familly, 
> Bytes.toBytes("B"))).equals("b"), "Column A value should be b");
>         Assert.isTrue(result.getValue(familly, Bytes.toBytes("C")) == null, 
> "Column C should not exists");
>     }
> {code}
> This assertion fails, the cell is not deleted but rather the value is empty:
> {code}
> hbase(main):029:0> scan 'my_test'
> ROW                                                   COLUMN+CELL             
>                                                                               
>                                                       
>  12345                                                column=default:A, 
> timestamp=1408473082290, value=a                                              
>                                                             
>  12345                                                column=default:B, 
> timestamp=1408473082290, value=b                                              
>                                                             
>  12345                                                column=default:C, 
> timestamp=1408473082290, value=      
> {code}
> This behavior is different than previous 4.8.x Cloudera version and is 
> currently corrupting all hive queries involving is null or is not null 
> operators on the columns mapped to hbase



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to