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

Comparator of NOT_EQUAL NULL is invalid for checkAndMutate

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8.0, 3.0.0-alpha-2, 2.4.9
    • 2.5.0, 3.0.0-alpha-3, 2.4.10
    • None
    • None
    • Hide
      The semantics of checkAndPut for null(or empty) value comparator is changed, the old match is always true.
      But we should consider that EQUAL or NOT_EQUAL for null check is a common usage, so the semantics of checkAndPut for matching null is correct now.
      There is rare use of LESS or GREATER null, so keep the semantics for them.
      Show
      The semantics of checkAndPut for null(or empty) value comparator is changed, the old match is always true. But we should consider that EQUAL or NOT_EQUAL for null check is a common usage, so the semantics of checkAndPut for matching null is correct now. There is rare use of LESS or GREATER null, so keep the semantics for them.

    Description

       In server side, checkAndMutate ignores CompareOperator for null or empty comparator value, but NOT_EQUAL should be treated specially.

      The check logic in HRegion#checkAndMutateInternal is as follows,

      boolean valueIsNull =
        comparator.getValue() == null || comparator.getValue().length == 0;
      if (result.isEmpty() && valueIsNull) {
        matches = true;
      } else if (result.size() > 0 && result.get(0).getValueLength() == 0 && valueIsNull) {
        matches = true;
        cellTs = result.get(0).getTimestamp();
      } else if (result.size() == 1 && !valueIsNull) {
        Cell kv = result.get(0);
        cellTs = kv.getTimestamp();
        int compareResult = PrivateCellUtil.compareValue(kv, comparator);
        matches = matches(op, compareResult);
      }

      For current logics, here are some  counter examples(Comparator value is set null),

      1. result is null, operator is NOT_EQUAL, but matches is true;
      2. result size >0, the value of the first cell is empty, operator is NOT_EQUAL, but matches is true;
      3. result size is 1, operator is NOT_EQUAL, but matches is false;

      Attachments

        Issue Links

          Activity

            People

              Xiaolin Ha Xiaolin Ha
              Xiaolin Ha Xiaolin Ha
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: