Divneet18 opened a new pull request, #2710:
URL: https://github.com/apache/phoenix/pull/2710
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://phoenix.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
PHOENIX-XXXX Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes, and
prefix it with the JIRA id, e.g. 'PHOENIX-XXXX Your PR title ...'.
6. If possible, provide a concise example to reproduce the issue for a
faster review.
-->
### What changes were proposed in this pull request?
- `ALTER INDEX ... CONSISTENCY = STRONG | EVENTUAL` now fails on the client
with a new error, `ALTER_INDEX_CONSISTENCY_NOT_SUPPORTED` (`ERROR 917
(43M28)`). The check is the first statement in `MetaDataClient#alterIndex`, so
nothing is written to `SYSTEM.CATALOG` and no CDC objects are created.
- The grammar still accepts the `CONSISTENCY` clause, so users get a clear
error and not a syntax error. Removing the check enables the existing
consistency handling again.
- `CREATE INDEX ... CONSISTENCY` and the other `ALTER INDEX` statements,
such as `REBUILD` and `DISABLE`, work as before.
- `IndexMaintainerConsistencyIT#testAlterIndexConsistency` is the only test
that runs `ALTER INDEX ... CONSISTENCY`. It is ignored until PHOENIX-8046 is
fixed, and the new `testAlterIndexConsistencyNotSupported` covers the error.
### Why are the changes needed?
`ALTER INDEX ... CONSISTENCY` (PHOENIX-7794) writes the new consistency only
to the index row in `SYSTEM.CATALOG`. Other clients and the region servers keep
cached metadata with the old consistency, the client that ran the ALTER can
lose the index from its cache and skip index maintenance, and the change is not
coordinated with the eventually consistent index consumers. The index can then
get out of sync with the data table. PHOENIX-8046 (#2658) fixes this. Until it
lands, the statement should be rejected. #2658 changes the same block of
`alterIndex`, so it can remove this check and the `@Ignore`.
### Does this PR introduce _any_ user-facing change?
Yes. On master and in the 5.3.1 and 5.3.2 releases, `ALTER INDEX ...
CONSISTENCY` changes the consistency of the index. With this PR, `ALTER INDEX
IDX ON S.T CONSISTENCY = EVENTUAL` fails with:
```
ERROR 917 (43M28): Changing index consistency with ALTER INDEX is not
supported yet. tableName=S.IDX
```
The check runs before the index is looked up, so an index that does not
exist gets the same error, also with `IF EXISTS`.
### How was this patch tested?
- New `IndexMaintainerConsistencyIT#testAlterIndexConsistencyNotSupported`.
It creates a table and an index, and runs `ALTER INDEX ... CONSISTENCY=STRONG`
and `CONSISTENCY=EVENTUAL`. It checks that both fail with
`ALTER_INDEX_CONSISTENCY_NOT_SUPPORTED`. It then reads the index and the data
table from `SYSTEM.CATALOG`, bypassing the client cache, and checks that the
index consistency is still unset and that no CDC index was created.
- With the check removed, the new test fails at the first ALTER (`ALTER
INDEX ... CONSISTENCY=STRONG should not be supported`).
- `IndexMaintainerConsistencyIT` passes locally: 2 tests pass and
`testAlterIndexConsistency` is skipped.
`testIndexMaintainerConsistencyFromPTable` covers `CREATE INDEX ...
CONSISTENCY`.
```
mvn install -DskipTests -pl phoenix-core-client,phoenix-core-server -am
mvn verify -pl phoenix-core -Dit.test=IndexMaintainerConsistencyIT
-Dtest=skip -Dsurefire.failIfNoSpecifiedTests=false
-Dit.failIfNoSpecifiedTests=false
```
### Was this patch authored or co-authored using generative AI tooling?
Co-authored-by: Claude Code (Claude Opus 5.5)
🤖 Co-authored with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]