Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-4692

ArrayIndexOutOfBoundsException in ScanRanges.intersectScan

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.14.0
    • Fix Version/s: 4.14.0, 5.0.0
    • Labels:
      None

      Description

      ScanRanges.intersectScan may fail with AIOOBE if a salted table is used.

      java.lang.ArrayIndexOutOfBoundsException: 1
      
      	at org.apache.phoenix.util.ScanUtil.getKey(ScanUtil.java:333)
      	at org.apache.phoenix.util.ScanUtil.getMinKey(ScanUtil.java:317)
      	at org.apache.phoenix.compile.ScanRanges.intersectScan(ScanRanges.java:371)
      	at org.apache.phoenix.iterate.BaseResultIterators.getParallelScans(BaseResultIterators.java:1074)
      	at org.apache.phoenix.iterate.BaseResultIterators.getParallelScans(BaseResultIterators.java:631)
      	at org.apache.phoenix.iterate.BaseResultIterators.<init>(BaseResultIterators.java:501)
      	at org.apache.phoenix.iterate.ParallelIterators.<init>(ParallelIterators.java:62)
      	at org.apache.phoenix.execute.ScanPlan.newIterator(ScanPlan.java:274)
      	at org.apache.phoenix.execute.BaseQueryPlan.iterator(BaseQueryPlan.java:364)
      	at org.apache.phoenix.execute.HashJoinPlan.iterator(HashJoinPlan.java:234)
      	at org.apache.phoenix.execute.DelegateQueryPlan.iterator(DelegateQueryPlan.java:144)
      	at org.apache.phoenix.execute.DelegateQueryPlan.iterator(DelegateQueryPlan.java:139)
      	at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:314)
      	at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:293)
      	at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
      	at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:292)
      	at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:285)
      	at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:1798)
      

      Script to reproduce:

      CREATE TABLE TEST (PK1 INTEGER NOT NULL, PK2 INTEGER NOT NULL,  ID1 INTEGER, ID2 INTEGER CONSTRAINT PK PRIMARY KEY(PK1 , PK2))SALT_BUCKETS = 4;
      upsert into test values (1,1,1,1);
      upsert into test values (2,2,2,2);
      upsert into test values (2,3,1,2);
      
      create view TEST_VIEW as select * from TEST where PK1 in (1,2);
      CREATE INDEX IDX_VIEW ON TEST_VIEW (ID1);
      
      
        select /*+ INDEX(TEST_VIEW IDX_VIEW) */ * from TEST_VIEW where ID1 = 1  ORDER BY ID2 LIMIT 500 OFFSET 0;
      

      That happens because we have a point lookup optimization which reduces RowKeySchema to a single field, while we have more than one slot due salting.
      James R. Taylor can you please take a look? I'm not sure whether it should be fixed on the ScanUtil level or we just should not use point lookup in such cases.

        Attachments

        1. PHOENIX-4692-IT.patch
          2 kB
          Sergey Soldatov
        2. PHOENIX-4692_v1.patch
          5 kB
          James R. Taylor
        3. PHOENIX-4692_v2.patch
          8 kB
          Wei Xue

          Activity

            People

            • Assignee:
              jamestaylor James R. Taylor
              Reporter:
              sergey.soldatov Sergey Soldatov
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: