[
https://issues.apache.org/jira/browse/PHOENIX-7778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132286#comment-18132286
]
Shubham Roy commented on PHOENIX-7778:
--------------------------------------
Thanks [~haridsv] for the detailed comment. I agree it is a generic index issue
and CDC is only an illustration. The same was discussed with [~kadir]
previously but I had forgotten to update the Jira. Your comment helps a lot.
> ALTER TABLE SET MULTI_TENANT=true on a table with a CDC object causes
> StringIndexOutOfBoundsException when querying the CDC index — should be
> blocked at DDL time
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: PHOENIX-7778
> URL: https://issues.apache.org/jira/browse/PHOENIX-7778
> Project: Phoenix
> Issue Type: Bug
> Components: core, phoenix
> Affects Versions: 5.3.0, 5.3.1
> Reporter: Shubham Roy
> Assignee: Shubham Roy
> Priority: Major
>
> When a Phoenix table has an associated CDC object, issuing ALTER TABLE SET
> MULTI_TENANT=true on it puts the CDC index into an irrecoverably inconsistent
> state. Any subsequent query on the CDC index that uses PARTITION_ID() or
> PHOENIX_ROW_TIMESTAMP() in the WHERE clause crashes with
> StringIndexOutOfBoundsException. The ALTER should be blocked with a clear
> error message at DDL time.
>
> Steps to Reproduce:
> {code:java}
> -- 1. Create a regular table
> CREATE TABLE PERF_TEST_SET1 (ID INTEGER NOT NULL PRIMARY KEY, V1 VARCHAR);
> -- 2. Create a CDC object
> CREATE CDC PERF_TEST_SET1_CDC ON PERF_TEST_SET1;
> -- 3. Alter to multi-tenant (this should be blocked, but currently is not)
> ALTER TABLE PERF_TEST_SET1 SET MULTI_TENANT=true;
> -- 4. Query the CDC index — crashes
> SELECT * FROM PHOENIX_CDC_INDEX_PERF_TEST_SET1_CDC
> WHERE " :PHOENIX_ROW_TIMESTAMP()" BETWEEN
> TO_TIMESTAMP('2026-02-28 01:00:00') AND TO_TIMESTAMP('2026-02-28
> 02:00:00')
> LIMIT 5; {code}
>
> Observed behaviour:
> {code:java}
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.substring(String.java:1967)
> at
> org.apache.phoenix.util.IndexUtil.getDataColumnFamilyName(IndexUtil.java:201)
> at
> org.apache.phoenix.schema.IndexUncoveredDataColumnRef.<init>(IndexUncoveredDataColumnRef.java:51)
> at
> org.apache.phoenix.compile.ExpressionCompiler.resolveColumn(ExpressionCompiler.java:414)
> at
> org.apache.phoenix.compile.WhereCompiler$WhereExpressionCompiler.resolveColumn(WhereCompiler.java:293)
> at
> org.apache.phoenix.compile.WhereCompiler$WhereExpressionCompiler.visit(WhereCompiler.java:275)
> at
> org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
> at
> org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:58)
> at
> org.apache.phoenix.parse.ComparisonParseNode.accept(ComparisonParseNode.java:41)
> at
> org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:58)
> at org.apache.phoenix.parse.AndParseNode.accept(AndParseNode.java:40)
> at
> org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:202)
> at
> org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:164)
> at
> org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:834)
> at
> org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:721)
> at
> org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:319)
> at
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:871)
> ... {code}
> Expected Behaviour:
> ALTER TABLE SET MULTI_TENANT=true should fail with a clear error message if
> the table has any CDC objects, e.g.:
> {code:java}
> ERROR: Cannot change MULTI_TENANT property on table 'PERF_TEST_SET1' because
> it has an associated CDC object 'PERF_TEST_SET1_CDC'. {code}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)