Skip to content

[BugFix] Fix lake fast-path ADD INDEX: CHAR/NGRAMBF correctness, durability across loads & compaction#75910

Open
meegoo wants to merge 12 commits into
StarRocks:mainfrom
meegoo:fix/lake-idg-index-typebugs
Open

[BugFix] Fix lake fast-path ADD INDEX: CHAR/NGRAMBF correctness, durability across loads & compaction#75910
meegoo wants to merge 12 commits into
StarRocks:mainfrom
meegoo:fix/lake-idg-index-typebugs

Conversation

@meegoo

@meegoo meegoo commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Why I'm doing:

The lake (shared-data) ADD INDEX / SET("bloom_filter_columns"=...) fast path (IDG .idx sidecar; PR #71689 / #75147 / #75337) had several correctness/durability defects, surfaced by the test_create_bitmap_index / test_create_bloom_filter / test_create_ngram_bloom_filter StarRocksTest cases. Verified on a shared-data cluster with the real basic_types_data (65,546 rows).

What I'm doing:

Five fixes: https://github.com/StarRocks/StarRocksTest/issues/11510

  1. CHAR padding. The page decoder strnlen-trims trailing \0 for TYPE_CHAR, so the fast path (which reads the source column back through a ColumnIterator) fed unpadded CHAR values to the bitmap dictionary / bloom filter, while the standard path and the query predicate use the value padded to the declared width. Result: bitmap over-pruned to empty, bloom false-negatived (missing rows). feed_index_from_column now re-pads CHAR to the declared width. (VARCHAR is untouched.)

  2. NGRAMBF / bloom index_properties. do_process_add_index_only hand-built TabletIndexPB and dropped index_properties (gram_num / case_sensitive / bloom_filter_fpp). It now builds the pb via TabletIndex::init_from_thrift + to_schema_pb, propagating all properties.

  3. Durability across new loads + compaction. The fast path changed the schema content (table_indices + per-column has_bitmap_index/is_bf_column) but reused the same schema_id/version. Every lake by-id schema cache (GS{id} metacache; GlobalTabletSchemaMap dedup, whose check_schema_unique_id ignores index flags; historical_schemas; SCHEMA_{id} file) then kept returning the stale pre-index schema, so data loaded after the index — and compaction output — built no index (compaction also deletes the input .idx, losing it permanently). FE now allocates a new schema_id+version (once, persisted for idempotent replay) and stamps it FE→BE (TAlterTabletReqV2OpAddIndexapply_add_index), so every cache misses and picks up the indexed schema. Existing rowsets carry no rowset_to_schema pin and resolve to metadata->schema(); their segments' missing footer index is served by the .idx sidecar until compaction rebuilds it inline.

  4. NGRAMBF routed to the legacy path. The fast-path .idx ngram bloom is not consulted at query time (verified: a footer ngram filters ~16k rows while the fast-path ngram does a full scan, no BloomFilterFilterRows). Until the BE fast-path ngram read is implemented, SchemaChangeIndexFastPathClassifier excludes NGRAMBF (same treatment as GIN/VECTOR), so ADD INDEX ... USING NGRAMBF takes the legacy LakeTableSchemaChangeJob (which rewrites a correct footer ngram). BITMAP keeps the fast path.

  5. bloom_filter_columns on an ngram column now rejected in the fast path. A column may carry at most one of {plain bloom, ngram bloom}; the regular path enforces this via IndexAnalyzer.analyseBfWithNgramBf, but the bloom fast path skipped it. Added the same validation before taking the fast path.

Validation

Re-ran the previously-failing StarRocksTest cases against a cluster running this PR (build of 50fe12d): all in-scope fast-path index cases pass — bitmap (char, largeint), bloom (bigint, char), all NGRAMBF variants, drop-index, and the PK cloud-native/native bf & bitmap cases. Remaining reds are out of this PR's scope: non-index suites (iceberg / range-distribution-split / rename-column), and the shared-nothing local persistent-index PK cases (which cannot run on a shared-data cluster).

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5

Known limitations / follow-ups

  • Pre-existing (dates from the original fast-path PRs, discovered while reviewing this one; tracked as a separate follow-up): on a table with a rollup / sync MV that does not contain the indexed column, the fast path dispatches the add-index task to every visible materialized index and BE fails that tablet ("ADD INDEX fast path: column not found in new schema"), cancelling the whole ALTER instead of skipping the projecting rollup like the legacy path does. Fix direction: dispatch/bump only the index metas whose schema contains the indexed columns.
  • The per-index schema-version bump marks the table as schema-evolved, which (by RewriteSimpleAggToMetaScanRule's conservative design) disables the shared-data min/max/count meta-scan rewrite for the table — the same effect as any other lake schema change (e.g. ADD COLUMN). Kept intentionally: the version monotonicity is what lets a concurrently-created partition's tablets reconcile to the indexed schema on their first load.
  • apply_add_index persists the new SCHEMA_{id} file synchronously on the publish path (one extra object-store PUT per tablet, once per ADD INDEX). Best-effort and non-fatal; kept as-is — a one-time DDL cost that serves cold by-id readers.

Copilot AI review requested due to automatic review settings July 6, 2026 10:59
@github-actions github-actions Bot added the 4.1 label Jul 6, 2026
@mergify mergify Bot assigned meegoo Jul 6, 2026
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Module-risk briefing — storage/lake

Review pitfall — fast-path index construction must fully mirror the standard write path. The diff changes AddIndexSchemaChange::feed_index_from_column/build_bitmap_for_column/build_bloom_for_column (CHAR re-padding) and SchemaChangeHandler::do_process_add_index_only (building TabletIndexPB via TabletIndex::init_from_thrift instead of copying fields by hand) — both are the lake ADD INDEX fast path (IDG) rebuilding index metadata outside the normal segment-rewrite path. History on this exact feature (#71689) shows this fast path has repeatedly diverged from the standard path in subtle ways: [[e:pr/StarRocks_starrocks/75147]] fixed three independent defects in the same fast path (page-cache key collision from a filename-less stream, missing non-PK gating, and no FE bloom-filter type validation) after it silently produced wrong/empty query results. The broader module pattern — non-SegmentWriter-mediated / bespoke construction paths quietly omitting metadata the standard path fills in — also shows up in [[e:pr/StarRocks_starrocks/74582]] and [[e:pr/StarRocks_starrocks/74222]] (vector-index metadata dropped by paths that bypass the normal writer setup).

Suggested focus for this PR: confirm there's test coverage proving the fast-path-built bitmap/bloom index and TabletIndexPB (including index_properties for NGRAMBF/bloom, and CHAR padding) are byte-for-byte/behaviorally equivalent to what the standard segment-rewrite path produces — not just that it compiles/runs, since prior bugs in this same fast path were silent (wrong query results) rather than crashes.

Provenance: from 20 merged bugfixes in storage/lake.


This is a history-backed heuristic from past merged bugfixes in the touched module, not a verdict — please weigh it against the actual change.


Note: the PR's description text doesn't match the actual diff — it describes a TxnInfoPB.colocate_column_count protobuf field renumbering, but the real diff (confirmed via gh pr diff) is the CHAR-padding/NGRAMBF fix in add_index_schema_change.cpp/schema_change.cpp analyzed above. Worth flagging to whoever owns this PR, in case the wrong description got attached.

@github-actions github-actions Bot requested review from sevev and srlch July 6, 2026 11:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes correctness issues in the lake ADD INDEX fast path so the generated bitmap/bloom/NGRAMBF indexes are byte-identical (and behaviorally consistent) with the standard segment-rewrite path.

Changes:

  • In the ADD INDEX fast path, build TabletIndexPB via TabletIndex::init_from_thrift() + to_schema_pb() so index_properties are preserved (e.g., gram_num, case_sensitive, bloom_filter_fpp) and validate indexed columns exist before calling the unchecked field_index() path.
  • Re-pad TYPE_CHAR slices back to the declared column width (with '\0') before feeding bitmap/bloom writers, avoiding mismatches caused by decoder trimming.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
be/src/storage/lake/schema_change.cpp Uses TabletIndex conversion to preserve index properties and adds pre-validation for missing columns in ADD INDEX fast path.
be/src/storage/lake/add_index_schema_change.cpp Adds TYPE_CHAR repadding in the index feed path and plumbs declared CHAR width into bitmap/bloom builders.

Comment thread be/src/storage/lake/schema_change.cpp
Comment thread be/src/storage/lake/schema_change.cpp
Comment thread be/src/storage/lake/add_index_schema_change.cpp
Comment thread be/src/storage/lake/schema_change.cpp
@wanpengfei-git wanpengfei-git requested review from a team July 8, 2026 07:38
@meegoo meegoo changed the title [BugFix] Fix lake IDG fast-add-index for CHAR (padding) and NGRAMBF/bloom (index_properties) [BugFix] Fix lake fast-path ADD INDEX: CHAR/NGRAMBF correctness, durability across loads & compaction Jul 8, 2026
meegoo and others added 5 commits July 9, 2026 10:48
…loom (index_properties)

Two type-specific correctness bugs in the lake (shared-data) ADD INDEX / SET
bloom_filter_columns fast path (IDG .idx sidecar):

1. CHAR columns: the page decoder strnlen-trims trailing '\0' padding when the
   fast path reads the source column back to build the index, so the bitmap
   dictionary / bloom filter were built from UNPADDED values. The standard
   segment-write path and the query predicate both use the CHAR value padded to
   the declared column width, so the fast-path index never matched at query time
   -> bitmap over-pruned to an empty result, bloom false-negatived (missing
   rows). Re-pad CHAR values back to the declared width with '\0' in
   feed_index_from_column so the fast-path index is byte-identical to the
   standard path.

2. NGRAMBF / plain bloom: do_process_add_index_only built TabletIndexPB by hand
   and dropped index_properties, so gram_num / case_sensitive / bloom_filter_fpp
   were lost -> NGRAMBF built with the wrong gram_num (default 4) never matched
   the query predicate's ngrams (no pruning). Build the pb via
   TabletIndex::init_from_thrift + to_schema_pb so all properties (and the
   schema-resolved column unique ids) are propagated exactly like the standard
   path.

Verified on a shared-data cluster with the real basic_types_data:
CHAR bitmap/bloom over-prune reproduced; largeint bitmap and bigint bloom
already work (their CI failures were cluster-instability flakes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: meegoo <meegoo.sr@gmail.com>
…ompaction

The lake ADD INDEX / SET bloom_filter_columns fast path (IDG) wrote .idx
sidecars for existing segments and edited the tablet-metadata schema content
(table_indices + per-column has_bitmap_index/is_bf_column), but REUSED the same
schema_id/schema_version. Every lake by-id schema cache assumes id==content
(get_cached_schema GS{id} metacache; GlobalTabletSchemaMap dedup, whose
check_schema_unique_id ignores index flags; historical_schemas; SCHEMA_{id}
file), so data loaded AFTER the index — and compaction output — kept resolving
the cached pre-index schema and built no index. Compaction additionally deletes
the input rowsets' IDG entries, losing the index permanently.

Fix: FE allocates a new schema_id+schema_version for the fast-path add-index
(once, at job build; persisted for idempotent replay) and stamps it onto the
base MaterializedIndexMeta (applyCatalogMutation, mirroring
LakeTableAsyncFastSchemaChangeJob), and forwards it to BE via
TAlterTabletReqV2 -> OpAddIndex. BE apply_add_index sets the new
id/version on the tablet-metadata schema and writes SCHEMA_{new_id}. The new id
makes every by-id cache miss and pick up the now-indexed schema, so future
loads and compaction build the index inline. This is a pure index-add
(columns unchanged): existing rowsets carry no rowset_to_schema pin and resolve
to metadata->schema(); their segments' missing footer index is served by the
.idx sidecar until compaction rebuilds it inline.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: meegoo <meegoo.sr@gmail.com>
Signed-off-by: meegoo <meegoo.sr@gmail.com>
…ath ngram not applied at read)

The lake IDG fast-path builds an .idx ngram bloom for NGRAMBF, but the query
read path never surfaces that IDG ngram entry, so LIKE predicates never prune
(verified on-cluster: a footer-defined ngram filters ~16k rows while the
fast-path ngram does a full scan with no BloomFilterFilterRows counter). Until
the BE fast-path ngram read is implemented, exclude NGRAMBF from the fast-path
classifier so ADD INDEX ... USING NGRAMBF takes the legacy LakeTableSchemaChangeJob
(which rewrites segments with a correct footer ngram, matching GIN/VECTOR
handling). BITMAP keeps the fast path; plain bloom_filter_columns is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: meegoo <meegoo.sr@gmail.com>
…in the lake fast path

A column may carry at most one of {plain bloom filter, ngram bloom filter}. The
regular schema-change path enforces this via IndexAnalyzer.analyseBfWithNgramBf,
but the lake bloom_filter_columns fast path (tryBuildLakeAddBloomFilterJob) did
not — so 'SET ("bloom_filter_columns"="c")' on a column that already has an
NGRAMBF index was silently accepted instead of erroring 'should only have one
bloom filter index or ngram bloom filter index'. Run the same validation before
taking the fast path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: meegoo <meegoo.sr@gmail.com>
@meegoo meegoo force-pushed the fix/lake-idg-index-typebugs branch from 50fe12d to 98971d8 Compare July 9, 2026 02:49
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 98971d8719

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fe/fe-core/src/main/java/com/starrocks/alter/SchemaChangeHandler.java Outdated
meegoo and others added 2 commits July 9, 2026 11:33
…ma-id bump

Two pre-existing tests encoded the old fast-path contract that this PR
intentionally changed:

- SchemaChangeIndexFastPathClassifierTest: NGRAMBF is now routed to the
  legacy path (the fast-path .idx ngram bloom is not consulted at query
  time), so it is no longer an accepted add-index fast-path type and
  isSupportedIndexType(NGRAMBF) is false.
- SchemaChangeHandlerLakeIndexFastPathTest: the tryBuild*() builders now
  read the base index meta's schema version to allocate a new schema
  id/version (durability fix). stubLakeTable() must stub
  getBaseIndexMetaId()/getIndexMetaByMetaId(), otherwise the builders NPE
  and return null (breaking the *_HappyPath and force-cancel-allowlist tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BNsDjnXjbty1eDHzZnFAEQ
Signed-off-by: meegoo <meegoo.sr@gmail.com>
…ablets

The lake fast-path ADD INDEX / bloom-filter durability fix allocates one new
schema id/version and bumps only the base index meta (applyCatalogMutation).
But populateAlterRequest stamped that id on every dispatched tablet, including
rollup / sync-MV index tablets whose FE meta keeps its old id — leaving those
tablets' BE schema id ahead of the catalog on a table with rollups.

Gate the stamp on indexMetaId == baseIndexMetaId so only base-index tablets
carry the new id; rollup tablets keep their existing schema id (their pre-fix
behavior). The dispatch already resolves a per-tablet indexMetaId, so plumb it
into populateAlterRequest and capture the base index meta id on the job. The
common no-rollup case is unchanged (base is the only index).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BNsDjnXjbty1eDHzZnFAEQ
Signed-off-by: meegoo <meegoo.sr@gmail.com>
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5f29b4a7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread be/src/storage/lake/meta_file.cpp
Comment thread fe/fe-core/src/main/java/com/starrocks/alter/LakeTableAddIndexJob.java Outdated
…volved tables

Full hardening of the fast-path ADD INDEX / bloom-filter schema-id bump so it
is durable across the two cases the single-id / base-only design missed:

1. Rollup / sync-MV indexes (FE). The dispatch fans an AlterReplicaTask out to
   every visible materialized index's tablets, but only the base index meta was
   bumped, so rollup tablets' BE schema id diverged from their unchanged FE
   meta. Allocate a distinct schema id/version per affected index meta (one
   getNextId() each; version = that meta's own version + 1), stamp each tablet
   with its own index's id (via the indexMetaId now passed to
   populateAlterRequest), and bump every affected meta in applyCatalogMutation.
   Keeps FE and BE schema ids aligned per index. Mirrors
   LakeTableAsyncFastSchemaChangeJob's per-index handling.

2. Non-PK tables that already fast-evolved (BE). When rowset_to_schema is
   populated, existing rowsets are pinned to a historical schema and both the
   read path and compaction's get_output_rowset_schema resolve through
   historical_schemas, bypassing metadata->schema() — so the schema-id bump was
   silently skipped there. apply_add_index now archives the indexed schema under
   the new id and repoints the pins that referenced the pre-index current schema
   to it, so those rowsets read via the .idx sidecar and compaction rebuilds the
   index inline. Rowsets pinned to older (fewer-column) schemas keep their pin;
   empty-map (fresh / never-evolved) tables are unchanged. Guarded on
   historical_schemas so replay is idempotent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BNsDjnXjbty1eDHzZnFAEQ
Signed-off-by: meegoo <meegoo.sr@gmail.com>
Signed-off-by: meegoo <meegoo.sr@gmail.com>
@meegoo meegoo force-pushed the fix/lake-idg-index-typebugs branch from 27e86fd to 224bf80 Compare July 9, 2026 10:05
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 224bf8001d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ved-table repoint, CHAR repad)

The BE Incremental Coverage report flagged the new lake fast-path ADD INDEX
durability code as uncovered. Add focused unit tests:

- meta_file_test: apply_add_index with new_schema_id set — (1) empty
  rowset_to_schema stamps schema id/version only; (2) fast-evolved table
  (non-empty rowset_to_schema) archives the indexed schema into
  historical_schemas[new_id] and repoints the pre-index-current-schema pins to
  it while leaving older-schema pins untouched, and is idempotent on replay.
- add_index_schema_change_test: do_process_add_index_only carries the
  FE-allocated new_index_schema_id/version into OpAddIndex; empty-columns index
  is rejected; and a CHAR column drives feed_index_from_column's repad_char path
  (char_pad_len = column.length()) for both BITMAP and BLOOM_FILTER — the fixture
  gains a CHAR c4 column (value column, mirrors the existing VARCHAR c2 and the
  CHAR write in rowset_test).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BNsDjnXjbty1eDHzZnFAEQ
Signed-off-by: meegoo <meegoo.sr@gmail.com>
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc5547c43b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…INDEX

FE Incremental Coverage flagged the new per-index schema-id code:
- LakeTableIndexFastPathJobTest: applyCatalogMutation now bumps EACH affected
  index meta (shallowCopy -> setSchemaId/setSchemaVersion -> put ->
  rebuildFullSchema) — tested with a base + rollup meta; and populateAlterRequest
  stamps a tablet's task with ITS index meta's new schema id (and skips a tablet
  whose index has no allocated entry).
- AlterReplicaTaskTest: setNewIndexSchema + toThrift carry new_index_schema_id /
  new_index_schema_version into TAlterTabletReqV2 under only_add_index.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BNsDjnXjbty1eDHzZnFAEQ
Signed-off-by: meegoo <meegoo.sr@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

@meegoo meegoo enabled auto-merge (squash) July 13, 2026 06:33
Comment thread be/src/storage/lake/meta_file.cpp Outdated
Comment thread be/src/storage/lake/meta_file.cpp
// schema_id but changes its content; every by-id schema cache would go
// stale). Per-index keeps FE/BE schema ids aligned across all the
// tablets the job dispatches to (dispatch covers every visible index).
for (Long affectedIndexMetaId : olapTable.getIndexMetaIdToMeta().keySet()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allocates a schema bump for every index meta (base + rollup / sync-MV), and dispatch fans ADD INDEX tasks to every meta's tablets. shouldUseAddIndexFastPath only gates on isCloudNativeTableOrMaterializedView, so a table with rollups takes this path. BE do_process_add_index_only returns InternalError when an index meta's schema lacks the indexed column (the field-existence guard), and the fast path deliberately does not fall back to legacy — so a rollup that omits the indexed column would fail the whole alter. Can you confirm this multi-index-meta case is handled (e.g. rollups always contain the indexed column, or such tables are excluded upstream)? All the new tests use a single base index, so this path is currently uncovered.

…han historical entry GC

Two review follow-ups on apply_add_index STEP 4:
- Gate create_schema_file on the schema id actually changing in this apply, so
  re-applying the same OpAddIndex (metadata replay on restart) does not repeat
  the remote object-store write. First apply behavior is unchanged.
- Document that a fully-repointed old_schema_id can leave its
  historical_schemas entry unreferenced, and that apply_opcompaction's
  historical_schemas GC reclaims it on the next compaction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BNsDjnXjbty1eDHzZnFAEQ
Signed-off-by: meegoo <meegoo.sr@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions

Copy link
Copy Markdown
Contributor

[FE Incremental Coverage Report]

pass : 1 / 1 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/task/AlterReplicaTask.java 1 1 100.00% []

@github-actions

Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

pass : 42 / 44 (95.45%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/storage/lake/meta_file.cpp 16 17 94.12% [438]
🔵 be/src/storage/lake/add_index_schema_change.cpp 16 17 94.12% [122]
🔵 be/src/storage/lake/schema_change.cpp 10 10 100.00% []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants