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

Queries that use an uncovered index with SALT_BUCKETS=0, we get /0 error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      I have not done extensive testing on it, but when I specified SALT_BUCKETS=0 while creating an index, I get no error and this is a valid use case to disable salting on index when the data table is salted:

      create table tsalt (k INTEGER PRIMARY KEY, v1 INTEGER) SALT_BUCKETS=4;
      upsert into tsalt (k, v1) VALUES (1, 100);
      create uncovered index tsaltidx on tsalt (PHOENIX_ROW_TIMESTAMP()) SALT_BUCKETS=0;

       

      From schema and hbase regions, it is correctly treated as no salting scenario.

       

      0: jdbc:phoenix:localhost> select salt_buckets from system.catalog where table_name = 'TSALTIDX' and salt_buckets is not null;

      --------------

      SALT_BUCKETS

      --------------
      --------------
      No rows selected (0.026 seconds)

       

      hbase:001:0> list_regions 'TSALTIDX'
                         SERVER_NAME |                                               REGION_NAME |  START_KEY |    END_KEY |  SIZE |   REQ |   LOCALITY |
       ----------------------------- | --------------------------------------------------------- | ---------- | ---------- | ----- | ----- | ---------- |
       localhost,16020,1708958003582 | TSALTIDX,,1708958225506.a72b20c15cecba23289a03cd6956ec15. |            |            |     0 |     3 |        0.0 |
       1 rows

      However, when I query through the index, I get an ArithmeticError for divide by zero.

      {{0: jdbc:phoenix:localhost> select /*+ INDEX(TSALT TSALTIDX) */ * from TSALT;Caused by: java.lang.ArithmeticException: / by zero
              at org.apache.phoenix.schema.SaltingUtil.getSaltingByte(SaltingUtil.java:79)
              at org.apache.phoenix.index.IndexMaintainer.buildDataRowKey(IndexMaintainer.java:916)
              at org.apache.phoenix.coprocessor.UncoveredIndexRegionScanner.scanIndexTableRows(UncoveredIndexRegionScanner.java:253)
              at org.apache.phoenix.coprocessor.UncoveredIndexRegionScanner.scanIndexTableRows(UncoveredIndexRegionScanner.java:274)
              at org.apache.phoenix.coprocessor.UncoveredIndexRegionScanner.next(UncoveredIndexRegionScanner.java:382)
              at org.apache.phoenix.coprocessor.BaseRegionScanner.nextRaw(BaseRegionScanner.java:56)
              at org.apache.phoenix.iterate.RegionScannerFactory$1.nextRaw(RegionScannerFactory.java:257)

      My suspicion is that table cells have number buckets stored as zero, so PTableImpl for the index gets constructed to return 0 from getBucketNum() and this is causing the divide by 0 error.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              haridsv Hari Krishna Dara
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: