airborne12 opened a new pull request, #71128:
URL: https://github.com/apache/doris/pull/71128

   ### Background
   
   `BUILD INDEX idx ON t [PARTITION (...)]` builds an index for data written 
before the index was added, and `ALTER TABLE t DROP INDEX idx PARTITION (...)` 
deletes the index files of some partitions. Both statements run only as index 
change jobs: `SchemaChangeHandler.process` hands them to 
`buildOrDeleteTableInvertedIndices`, which creates one `IndexChangeJob` per 
partition. The master-only FE config `enable_light_index_change` (default 
`true`) switches the light index change machinery on and off.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #32143 (introduced the silent branch)
   PR Type: Bugfix
   
   Problem Summary:
   
   With `enable_light_index_change = false`, `BUILD INDEX` and `DROP INDEX ... 
PARTITION` return OK but create no index change job, so nothing is built or 
dropped and the user gets no sign of it. This PR makes both statements fail 
with an error that names the config.
   
   ```sql
   ADMIN SET FRONTEND CONFIG ("enable_light_index_change" = "false");
   BUILD INDEX idx_v1 ON t;
   -- before: Query OK, no job in SHOW BUILD INDEX, nothing built
   -- after:  ERROR ... BUILD INDEX and DROP INDEX ... PARTITION require 
enable_light_index_change=true
   ```
   
   ### Details
   
   - **Frequency:** Always, when `enable_light_index_change` is `false` and a 
user runs `BUILD INDEX` or `DROP INDEX ... PARTITION`. The config defaults to 
`true`, so only clusters that turned it off are affected.
   - **Root cause:** in `SchemaChangeHandler.process`, the `buildIndexChange` 
branch calls `buildOrDeleteTableInvertedIndices` only inside `if 
(Config.enable_light_index_change)` and has no else branch. When the config is 
off, the statement falls through and returns normally.
   - **Why existing tests missed it:** FE unit tests: 
`SchemaChangeHandlerTest`, `IndexChangeJobTest` and `CloudIndexTest` run `BUILD 
INDEX` and `DROP INDEX ... PARTITION` only with the config at its default 
`true`; the only test that turns it off (`VariantValuesIndexChangeTest`) checks 
ADD of a VARIANT values index. Regression suites: the 
`inverted_index_p0/index_change` and `cloud_build_index` suites never change 
this FE config.
   - **Fix:** reject the statement in the same branch with a `DdlException` 
when the config is off. `BuildIndexOp` and a partition scoped `DROP INDEX` 
change no table metadata before this point, and a partition scoped `DROP INDEX` 
must be the only clause of its statement, so a rejected statement leaves the 
table unchanged.
   - **Behavior change:** with `enable_light_index_change = false`, `BUILD 
INDEX` and `DROP INDEX ... PARTITION` return an error instead of OK. Nothing 
changes while the config is `true`, its default.
   - **Other paths and branches:** the other users of the config already fall 
back correctly: ADD INDEX and full-table DROP INDEX take the heavy schema 
change path when it is off, and the light DROP INDEX pre-check returns early. 
The same silent branch is on branch-3.1, branch-4.0, branch-4.1 and branch-4.2; 
on branch-4.1 and later it also covers `DROP INDEX ... PARTITION`, which #62181 
added.
   
   ### Testing
   
   - New FE UT 
`SchemaChangeHandlerTest#testIndexJobStatementsRejectedWhenLightIndexChangeDisabled`:
 with the config off, `BUILD INDEX`, `BUILD INDEX ... PARTITION` and `DROP 
INDEX ... PARTITION` must throw, and no index change job is created. Without 
the fix it fails with `Expected java.lang.Exception to be thrown, but nothing 
was thrown` on `BUILD INDEX`; with the fix it passes.
   - `SchemaChangeHandlerTest`, `IndexChangeJobTest`, `CloudIndexTest` and 
`VariantValuesIndexChangeTest`: 86 tests, all pass locally.
   - `build.sh --fe`: build succeeds with 0 checkstyle violations.
   
   ### Release note
   
   With `enable_light_index_change = false`, `BUILD INDEX` and `ALTER TABLE ... 
DROP INDEX ... PARTITION` now fail with an error instead of returning OK 
without doing anything.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Claude Code (Claude Opus 5.5)
   - Generated: code, test, this description
   - Human review: pending author review
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to