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

checkAndMutateApi doesn't work correctly on 0.98.19+

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.98.24
    • None
    • None
    • Reviewed

    Description

      Below is the test case. It uses some Phoenix APIs for getting hold of admin and HConnection but should be easily adopted for an HBase IT test. The second checkAndMutate should return false but it is returning true. This test fails with HBase-0.98.23 and works fine with HBase-0.98.17

      @Test
          public void testCheckAndMutateApi() throws Exception {
              byte[] row = Bytes.toBytes("ROW");
              byte[] tableNameBytes = Bytes.toBytes(generateUniqueName());
              byte[] family = Bytes.toBytes(generateUniqueName());
              byte[] qualifier = Bytes.toBytes("QUALIFIER");
              byte[] oldValue = null;
              byte[] newValue = Bytes.toBytes("VALUE");
              Put put = new Put(row);
              put.add(family, qualifier, newValue);
              try (Connection conn = DriverManager.getConnection(getUrl())) {
                  PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class);
                  try (HBaseAdmin admin = phxConn.getQueryServices().getAdmin()) {
                      HTableDescriptor tableDesc = new HTableDescriptor(
                              TableName.valueOf(tableNameBytes));
                      HColumnDescriptor columnDesc = new HColumnDescriptor(family);
                      columnDesc.setTimeToLive(120);
                      tableDesc.addFamily(columnDesc);
                      admin.createTable(tableDesc);
                      HTableInterface tableDescriptor = admin.getConnection().getTable(tableNameBytes);
                      assertTrue(tableDescriptor.checkAndPut(row, family, qualifier, oldValue, put));
                      Delete delete = new Delete(row);
                      RowMutations mutations = new RowMutations(row);
                      mutations.add(delete);
                      assertTrue(tableDescriptor.checkAndMutate(row, family, qualifier, CompareOp.EQUAL, newValue, mutations));
                      assertFalse(tableDescriptor.checkAndMutate(row, family, qualifier, CompareOp.EQUAL, newValue, mutations));
                  }
              }
          }
      

      FYI, apurtell, jamestaylor, lhofhansl.

      Attachments

        1. HBASE-17096-0.98.patch
          2 kB
          Andrew Kyle Purtell
        2. HBASE-17096-0.98.v2.patch
          4 kB
          Heng Chen

        Issue Links

          Activity

            People

              chenheng Heng Chen
              samarthjain Samarth Jain
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: