airborne12 opened a new pull request, #71137: URL: https://github.com/apache/doris/pull/71137
### Background With #71130, `ADD INDEX ... BUILD IMMEDIATE` on a local INVERTED or ANN index first journals the new index metadata (`TableAddOrDropInvertedIndicesInfo`), then creates and journals one `IndexChangeJob` per partition that builds the index for the partition's existing data. Both happen under the table write lock in `SchemaChangeHandler.process`. Replay rebuilds each from its own journal record. ### What problem does this PR solve? Issue Number: #71129 Related PR: #71130 (adds BUILD IMMEDIATE; this PR is stacked on it and depends on it) PR Type: Enhancement Problem Summary: If the master stops after the metadata record is journaled but before the build job of every partition is, a new master replays the index but has no build job for the missing partitions, so their existing data stays unindexed until someone runs BUILD INDEX. A retry with IF NOT EXISTS does not help, because it stops at the duplicate index check. This PR records which indexes BUILD IMMEDIATE builds in the metadata record itself, and the master submits the build jobs that are still missing after a failover. ### Details - **Before and after:** before, an FE failover between the two journal writes left the new index without build jobs for some partitions. After, every FE that applies the metadata record remembers which partitions of those indexes still lack a build job; each build job, submitted or replayed, clears its partition, and the master daemon submits jobs for what is left once the table is in NORMAL state. It skips partitions and indexes that were dropped in the meantime. - **Configs and defaults:** none. - **Impact on existing users:** none outside BUILD IMMEDIATE. `TableAddOrDropInvertedIndicesInfo` gains an optional `buildIndexIds` field; records written by older FEs read it as empty, and older FEs ignore it. ### Testing - New FE UT `SchemaChangeHandlerTest#testBuildImmediateJobsRecoveredAfterFailover`: replays a BUILD IMMEDIATE metadata record and the build job of one partition, as a new master would, and checks that the master submits exactly one job for the other partition and nothing more on a second pass. With the recovery methods stubbed out it fails (no pending build is recorded). - New FE UT `TableAddOrDropInvertedIndicesInfoTest`: `buildIndexIds` survives write and read, and a record without the field reads as empty. - `assertAddIndexRuns` in `SchemaChangeHandlerTest` now also checks that a normal BUILD IMMEDIATE leaves nothing pending. - `SchemaChangeHandlerTest` (53 tests), `IndexChangeJobTest`, `CloudIndexTest`, `VariantValuesIndexChangeTest` pass locally. ### Notes for Reviewers The pending partitions are derived from journal records and are not written to the image. They are lost only if every FE restarts from an image whose last journal is that metadata record and the old master's build jobs were never journaled; BUILD INDEX still builds them then. A failed submission is logged and not retried, for the same reason. Please review only the last commit; the others belong to #71130. ### Release note None ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: code, tests, 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]
