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

Toshihiro Suzuki commented on HBASE-25797:
------------------------------------------

Thank you [~bryson],

Can you please try to call the get() method of the CompletableFuture object 
returned by table.put() as follows:
{code}
// add r1
table.put(Arrays.asList(
 new Put(Bytes.toBytes("r1")).addColumn(COL_FAMILY, Bytes.toBytes("q1"), 
Bytes.toBytes("v1")))).get();
{code}

As the *table* is AysncTable, we need to wait for table.put() to complete 
before calling table.checkAndMutate(). Thanks.

> Batch version of checkAndMutate on AsyncTable always returns false
> ------------------------------------------------------------------
>
>                 Key: HBASE-25797
>                 URL: https://issues.apache.org/jira/browse/HBASE-25797
>             Project: HBase
>          Issue Type: Bug
>          Components: Client
>    Affects Versions: 2.4.1
>            Reporter: Hochul Shin
>            Priority: Minor
>              Labels: bug
>
> Batch version of CheckAndMutate always returns false whereas non-batch 
> version works fine. 
> The code is like: 
>  
> {code:java}
> AysncTable<?> table = connection.getTable(tableName, executorService);
> ...
> // add r1
> table.put(Arrays.asList(
>  new Put(Bytes.toBytes("r1")).addColumn(COL_FAMILY, Bytes.toBytes("q1"), 
> Bytes.toBytes("v1"))));
> CheckAndMutate checkAndMutate1 = 
> CheckAndMutate.newBuilder(Bytes.toBytes("r1"))
>  .ifNotExists(COL_FAMILY, Bytes.toBytes("q1"))
>  .build(new Put(Bytes.toBytes("r1")).addColumn(COL_FAMILY, 
> Bytes.toBytes("q1"), Bytes.toBytes("v1")));
> CheckAndMutate checkAndMutate2 = 
> CheckAndMutate.newBuilder(Bytes.toBytes("r2"))
>  .ifNotExists(COL_FAMILY, Bytes.toBytes("q2"))
>  .build(new Put(Bytes.toBytes("r2")).addColumn(COL_FAMILY, 
> Bytes.toBytes("q2"), Bytes.toBytes("v2")));
> {code}
>  
> With batch version of checkAndMutate
> {code:java}
> List<CompletableFuture<CheckAndMutateResult>> results =
>     table.checkAndMutate(Arrays.asList(checkAndMutate1, checkAndMutate2));
> System.out.println("first: " + results.get(0).join().isSuccess());  // false
> System.out.println("second: " + results.get(1).join().isSuccess()); //false!
> {code}
>  
>  
> Even it returned false, the r1 was written to the table. (timestamp was 
> updated) 
>  
> With non-batch version of checkAndMutate
>  
> {code:java}
> CompletableFuture<CheckAndMutateResult> result1 = 
> table.checkAndMutate(checkAndMutate1);
>  CompletableFuture<CheckAndMutateResult> result2 = 
> table.checkAndMutate(checkAndMutate2);
> System.out.println("first: " + result1.join().isSuccess()); // false 
> System.out.println("second: " + result2.join().isSuccess()); // true as 
> expected
> {code}
>  
> As expected r1 wasn't written to the table. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to