Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-25796

Batch version of checkAndMutate on AsyncTable always returns false

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • 2.4.1
    • None
    • Client
    • None
    • Hide
      client:
         'org.apache.commons:commons-configuration2:2.7'
         'org.apache.hadoop:hadoop-hdfs:2.7.3'
         'org.apache.hbase:hbase-client:2.4.1'

      server:
         hbase: 2.2.6
      Show
      client:    'org.apache.commons:commons-configuration2:2.7'    'org.apache.hadoop:hadoop-hdfs:2.7.3'    'org.apache.hbase:hbase-client:2.4.1' server:    hbase: 2.2.6

    Description

      Batch version of CheckAndMutate always returns false whereas non-batch version works fine. 

      The code is like: 

      ```

      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")));

      ```

      With batch version of checkAndMutate

      ```

      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!

      ```

      Even it returned false, the item was written to the table. 

       

      With non-batch version of checkAndMutate

      ```

      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

      ```

      As expected r1 wasn't written to the table. 

      Attachments

        Activity

          People

            Unassigned Unassigned
            bryson Hochul Shin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: