Xiaolin Ha created HBASE-26742:
----------------------------------
Summary: Comparator of NOT_EQUAL NULL is invalid for checkAndMutate
Key: HBASE-26742
URL: https://issues.apache.org/jira/browse/HBASE-26742
Project: HBase
Issue Type: Bug
Affects Versions: 2.0.0, 3.0.0-alpha-1
Reporter: Xiaolin Ha
Assignee: Xiaolin Ha
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,
{code:java}
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);
}{code}
For current logics, here are some counter examples(Comparator value is set
null),
# result is null, operator is NOT_EQUAL, but matches is true;
# result size >0, the value of the first cell is empty, operator is NOT_EQUAL,
but matches is true;
# result size is 1, operator is NOT_EQUAL, but matches is false;
--
This message was sent by Atlassian Jira
(v8.20.1#820001)