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

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: #68674 (source), #70357 (partition DROP INDEX on branch-4.1, 
which already brought part of this fix), #69444 (related master fix, not 
included)
   
   Problem Summary:
   
   Pick of apache/doris#68674 to branch-4.1.
   
   On the light index change path, `DROP INDEX` publishes the index metadata 
and writes the edit log first, and only then submits its delete jobs in 
`buildOrDeleteTableInvertedIndices`. When job submission throws, the statement 
fails but the index is already gone from `SHOW INDEX`. #68674 runs the checks 
that can reject those jobs before any ALTER clause touches table metadata, and 
also rejects a light `ADD INDEX` and a light full-table `DROP INDEX` in one 
statement, whose delete jobs share one direction flag (so `DROP INDEX old, ADD 
INDEX new` kept the files of `old`, and `ADD INDEX new, DROP INDEX old` deleted 
the files of `new`).
   
   branch-4.1 already has part of this fix: #70357 (the 4.1 backport of #62181, 
#69442 and #69443) added `isLightDropIndexSupported` and an early 
`checkLightDropIndexJobConflicts` call that rejects an unfinished index change 
job before the clause loop. Still missing on branch-4.1, and added by this pick:
   
   - the compute group check (`getCloudClusterName`) before the clause loop. In 
cloud mode, a light `DROP INDEX` without a compute group still dropped the 
index metadata and then failed with `It should specify a cluster when submit 
build index job.`
   - the rejection of a light `ADD INDEX` together with a light full-table 
`DROP INDEX`: `Can not add and drop indexes in one ALTER statement, please run 
them in separate statements.`
   - the two unit tests of #68674.
   
   ### Details
   
   - **Source:** apache/doris#68674, squash merge commit 
2fb774e8cd11e737a328cf8f3656453b0259dd82 (one parent; its diff equals the PR 
diff), picked with `git cherry-pick -x`.
   - **Pick type:** cherry-pick with conflicts, resolved by hand. The source 
PR's follow-ups #69442 and #69443 are already on branch-4.1 through #70357, and 
the single-scan conflict check of #69441 is in branch-4.1's 
`checkNoIndexChangeJobOnPartitions` too. #69444 (an ALTER that also needs heavy 
work runs as a heavy schema change) is a separate fix and is not part of this 
pick.
   - **Conflict in `SchemaChangeHandler.java`** (content conflict in 6 
regions). Cause: branch-4.1 still uses the legacy `AlterClause` / 
`DropIndexClause` / `CreateIndexClause` API instead of master's `AlterOp` / 
`DropIndexOp` / `CreateIndexOp`, and #70357 added a smaller version of the same 
pre-check under another name. Resolution:
     - The pre-check is master's `checkLightDropIndexPreconditions`, replacing 
branch-4.1's `checkLightDropIndexJobConflicts` at the same call site, before 
the partition DROP INDEX check and the clause loop, as on master. It takes 
`List<AlterClause>` and `throws UserException` (for `getCloudClusterName`).
     - The ADD+DROP rejection tests 
`CreateIndexClause.getIndex().isLightAddIndexSupported(...)`. The clause loop 
on this branch already calls `getIndex()` on the same clause before 
`processAddIndex`.
     - `isLightDropIndexSupported` keeps branch-4.1's cloud rule (`NGRAM_BF`, 
`INVERTED`). Master's `BLOOMFILTER` case comes from master's light BLOOMFILTER 
index change, which branch-4.1 does not have (`Index.isLightAddIndexSupported` 
on this branch has no `BLOOMFILTER` case either). The comment says `NGRAM_BF` 
instead of `NGRAM_BF and BfIndex` for the same reason.
     - `checkNoIndexChangeJobOnPartitions` keeps branch-4.1's body: one scan of 
the index change jobs and the message `has an unfinished index change job, 
please retry after it finishes.`, which is what master has today after #69441 
and #69443. #68674's version, a per-partition 
`hasIndexChangeJobOnPartition(..., true)` loop with the message `has been built 
specified index`, was later replaced on master by that body.
   - **Test adaptation in `SchemaChangeHandlerTest.java`** (applied without 
conflict): `testDropIndexRejectedByIndexChangeJobKeepsMetadata` expects `has an 
unfinished index change job`, the message of this branch and of master's 
current version of the same test.
   
   Hunk audit against #68674:
   
   | File | Source hunk | Status |
   | --- | --- | --- |
   | SchemaChangeHandler.java | `@@ -2388,6 +2388,11 @@` call of the pre-check 
before the clause loop | Adapted: replaces the 
`checkLightDropIndexJobConflicts` call of #70357 at the same point; passes 
`alterClauses` |
   | SchemaChangeHandler.java | `@@ -2641,21 +2646,7 @@` clause loop uses 
`isLightDropIndexSupported` | N-A: already on branch-4.1 through #70357 (`found 
!= null && isLightDropIndexSupported(found, enableAddIndexForNewData)`) |
   | SchemaChangeHandler.java | `@@ -3921,6 +3912,63 @@` 
`isLightDropIndexSupported`, `checkLightDropIndexPreconditions`, 
`checkNoIndexChangeJobOnPartitions` | Adapted: helper and conflict scan already 
on branch-4.1; renamed the pre-check, added the ADD+DROP rejection, the compute 
group check and the comments; kept the branch's cloud rule and conflict scan |
   | SchemaChangeHandlerTest.java | `@@ -1293,6 +1293,96 @@` two new tests | 
Adapted: expected message `has an unfinished index change job` |
   
   ### Release note
   
   Fix `DROP INDEX` removing index metadata even though the statement failed 
because of an unfinished index change job on the same partition or, in cloud 
mode, a missing compute group. An ALTER TABLE statement that adds and drops 
indexes on the light index change path is now rejected; run the ADD INDEX and 
DROP INDEX in separate statements.
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   Local results on this commit, JDK 17:
   - `./build.sh --fe`: passed, including checkstyle.
   - `./run-fe-ut.sh --run 
org.apache.doris.alter.SchemaChangeHandlerTest,org.apache.doris.alter.IndexChangeJobTest`:
 51 tests, 0 failures, 0 errors (SchemaChangeHandlerTest 32, IndexChangeJobTest 
19). The surefire report lists both new tests, 
`testDropIndexRejectedByIndexChangeJobKeepsMetadata` and 
`testLightAddAndDropIndexInOneStatementRejected`, as passed.
   - Not run locally: regression tests and cloud mode. The compute group check 
runs only in cloud mode and has no unit test, as in #68674.
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. A rejected light `DROP INDEX` now leaves the table unchanged 
when no compute group is set (cloud mode), and a statement with a light `ADD 
INDEX` and a light full-table `DROP INDEX` is rejected.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   🤖 Generated 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]


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

Reply via email to