JeongMin Ju created HBASE-30033:
-----------------------------------

             Summary: Scan.setBatch() validation can be bypassed by calling 
setBatch() before setFilter()
                 Key: HBASE-30033
                 URL: https://issues.apache.org/jira/browse/HBASE-30033
             Project: HBase
          Issue Type: Bug
          Components: Client
    Affects Versions: 2.5.11
            Reporter: JeongMin Ju


Scan.setBatch(int) validates that the scan does not have a filter with 
hasFilterRow() == true, throwing IncompatibleFilterException if it does. 
However, Scan.setFilter(Filter) does not perform the reverse check against an 
existing batch setting.

  This means calling setBatch() before setFilter() silently creates an invalid 
Scan configuration that setBatch() was designed to prevent:

  {code:java}
  // This correctly throws IncompatibleFilterException
  Scan scan = new Scan();
  scan.setFilter(new PageFilter(10));
  scan.setBatch(5); // throws IncompatibleFilterException

  // This silently creates the same invalid combination
  Scan scan = new Scan();
  scan.setBatch(5);              // succeeds - no filter yet
  scan.setFilter(new PageFilter(10)); // succeeds - no batch check
  // scan now has both batch and hasFilterRow()=true filter
  {code}

  When this invalid Scan is executed, setBatch splits rows into partial 
results, but filterRow() operates on partial data instead of the full row, 
producing incorrect results.

  Fix suggestion: Add validation in setFilter(Filter) to check if batch is 
already set:

  {code:java}
  public Scan setFilter(Filter filter) {
    super.setFilter(filter);
    if (this.batch > 0 && filter != null && filter.hasFilterRow()) {
      throw new IncompatibleFilterException(
        "Cannot set a filter that returns true for hasFilterRow on a scan with 
batch set");
    }
    return this;
  }
  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to