[ 
https://issues.apache.org/jira/browse/PHOENIX-7238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hari Krishna Dara updated PHOENIX-7238:
---------------------------------------
    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| +-------------+ 
\{+}{}}}{{{}--------------\{+}{}}}{{{}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.

  was:
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|

+--------------+
{+}--------------{+}{}}}\{{{}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.


> Zero is accepted for SALT_BUCKETS, but queries fail
> ---------------------------------------------------
>
>                 Key: PHOENIX-7238
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7238
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Hari Krishna Dara
>            Priority: Minor
>
> 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| +-------------+ 
> \{+}{}}}{{{}--------------\{+}{}}}{{{}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.



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

Reply via email to