Skip to content

[BugFix] Fix num_short_key_columns mismatch in partial tablet schema#70586

Merged
wyb merged 1 commit into
StarRocks:mainfrom
luohaha:fix/short-key-mismatch-in-partial-schema
Mar 20, 2026
Merged

[BugFix] Fix num_short_key_columns mismatch in partial tablet schema#70586
wyb merged 1 commit into
StarRocks:mainfrom
luohaha:fix/short-key-mismatch-in-partial-schema

Conversation

@luohaha
Copy link
Copy Markdown
Contributor

@luohaha luohaha commented Mar 20, 2026

Why I'm doing:

Fix BE DCHECK crash num_short_keys <= sort_key_idxes.size() in SeekTuple::short_key_encode during column-mode partial update on primary key tables with separate sort keys (e.g. ORDER BY(k3, k2)).

TabletSchema::create copies num_short_key_columns from the source schema (e.g. 2), but sort_key_idxes in the partial schema may be empty when sort key columns are not in the partial column set. _init_from_pb then falls back to using key columns as sort keys (e.g. size=1), creating an inconsistency: num_short_key_columns(2) > sort_key_idxes.size()(1).

What I'm doing:

After constructing the partial tablet schema, ensure num_short_key_columns <= sort_key_idxes.size() to keep them consistent.

Trigger SQL:

CREATE TABLE tab1 (k0 int NOT NULL, k1 int, k2 int, k3 int, k4 int, k5 int, v1 int, v2 int)
PRIMARY KEY(k0) DISTRIBUTED BY HASH(k0) BUCKETS 1 ORDER BY(k3, k2)
PROPERTIES ("replication_num" = "1");

INSERT INTO tab1 VALUES (1,1,1,1,1,1,1,1);
SET partial_update_mode = 'column';
UPDATE tab1 SET k4 = 1;  -- crashes in ASAN build

Fixes https://github.com/StarRocks/StarRocksTest/issues/11136

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
  • Feature removed
  • 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 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.0
    • 3.5
    • 3.4

@luohaha luohaha requested a review from a team as a code owner March 20, 2026 06:56
When creating a partial tablet schema for column-mode partial update
on a table with separate sort keys (ORDER BY), num_short_key_columns
is copied from the source schema but sort_key_idxes may be empty if
the sort key columns are not in the partial schema. _init_from_pb then
falls back sort_key_idxes to key columns, creating a mismatch where
num_short_key_columns > sort_key_idxes.size(). This causes a DCHECK
crash in SeekTuple::short_key_encode during segment writing in ASAN
builds.

Fix by ensuring num_short_key_columns <= sort_key_idxes.size() after
constructing the partial schema.

Fixes StarRocks/StarRocksTest#11136

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: luohaha <18810541851@163.com>
@luohaha luohaha force-pushed the fix/short-key-mismatch-in-partial-schema branch from 5c4952f to 901757e Compare March 20, 2026 07:08
@CelerData-Reviewer
Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ 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".

@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 : 0 / 0 (0%)

@github-actions
Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

pass : 4 / 4 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/storage/tablet_schema.cpp 4 4 100.00% []

@github-actions github-actions Bot removed the 3.4 label Mar 20, 2026
@wyb wyb merged commit ea8b566 into StarRocks:main Mar 20, 2026
65 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport branch-4.0

@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport branch-3.5

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 20, 2026

backport branch-4.0

✅ Backports have been created

Details

Cherry-pick of ea8b566 has failed:

On branch mergify/bp/branch-4.0/pr-70586
Your branch is up to date with 'origin/branch-4.0'.

You are currently cherry-picking commit ea8b566747.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   be/src/storage/tablet_schema.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   be/test/storage/tablet_schema_test.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 20, 2026

backport branch-3.5

✅ Backports have been created

Details

Cherry-pick of ea8b566 has failed:

On branch mergify/bp/branch-3.5/pr-70586
Your branch is up to date with 'origin/branch-3.5'.

You are currently cherry-picking commit ea8b566747.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   be/src/storage/tablet_schema.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   be/test/storage/tablet_schema_test.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

mergify Bot pushed a commit that referenced this pull request Mar 20, 2026
…70586)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit ea8b566)

# Conflicts:
#	be/test/storage/tablet_schema_test.cpp
mergify Bot pushed a commit that referenced this pull request Mar 20, 2026
…70586)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit ea8b566)

# Conflicts:
#	be/test/storage/tablet_schema_test.cpp
@github-actions github-actions Bot added the 4.0 label Mar 20, 2026
luohaha added a commit that referenced this pull request Mar 20, 2026
PrimaryKeyEncodingType does not exist on branch-4.0. Keep only the
short key consistency test from #70586.

Signed-off-by: luohaha <18810541851@163.com>
wanpengfei-git pushed a commit that referenced this pull request Mar 20, 2026
…(backport #70586) (#70602)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
mergify Bot added a commit that referenced this pull request Mar 20, 2026
…(backport #70586) (#70602)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
(cherry picked from commit 91e8995)
wanpengfei-git pushed a commit that referenced this pull request Mar 20, 2026
…(backport #70586) (backport #70602) (#70610)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
jayakasadev pushed a commit to jayakasadev/starrocks that referenced this pull request Mar 25, 2026
…tarRocks#70586)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@luohaha
Copy link
Copy Markdown
Contributor Author

luohaha commented Apr 3, 2026

https://github.com/Mergifyio backport branch-4.1

@luohaha
Copy link
Copy Markdown
Contributor Author

luohaha commented Apr 3, 2026

https://github.com/Mergifyio backport branch-4.1.0

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 3, 2026

backport branch-4.1

✅ Backports have been created

Details

mergify Bot pushed a commit that referenced this pull request Apr 3, 2026
…70586)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit ea8b566)
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 3, 2026

backport branch-4.1.0

✅ Backports have been created

Details

mergify Bot pushed a commit that referenced this pull request Apr 3, 2026
…70586)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit ea8b566)
wanpengfei-git pushed a commit that referenced this pull request Apr 3, 2026
…(backport #70586) (#71275)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DanRoscigno pushed a commit to chris-celerdata/starrocks that referenced this pull request Apr 6, 2026
…tarRocks#70586)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wanpengfei-git pushed a commit that referenced this pull request Apr 8, 2026
…(backport #70586) (#71274)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
luohaha added a commit that referenced this pull request May 8, 2026
…70586)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wanpengfei-git pushed a commit that referenced this pull request May 8, 2026
…(backport #70586) (#70603)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wanpengfei-git pushed a commit that referenced this pull request May 8, 2026
…(backport #70586) (backport #70603) (#72995)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wanpengfei-git pushed a commit that referenced this pull request May 12, 2026
…(backport #70586) (backport #70603) (#73089)

Signed-off-by: luohaha <18810541851@163.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Yixin Luo <18810541851@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

4 participants