Skip to content

[BugFix] Fix num_short_key_columns mismatch in partial tablet schema (backport #70586)#71274

Merged
wanpengfei-git merged 2 commits into
branch-4.1from
mergify/bp/branch-4.1/pr-70586
Apr 8, 2026
Merged

[BugFix] Fix num_short_key_columns mismatch in partial tablet schema (backport #70586)#71274
wanpengfei-git merged 2 commits into
branch-4.1from
mergify/bp/branch-4.1/pr-70586

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Apr 3, 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:

…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)
luohaha
luohaha previously approved these changes Apr 3, 2026
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) April 3, 2026 10:45
luohaha
luohaha previously approved these changes Apr 3, 2026
The Calendar class was used without being imported after backport #71046.
@luohaha luohaha force-pushed the mergify/bp/branch-4.1/pr-70586 branch from 1d35557 to b4234d0 Compare April 3, 2026 13:10
@wanpengfei-git wanpengfei-git merged commit 1535748 into branch-4.1 Apr 8, 2026
68 of 73 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-4.1/pr-70586 branch April 8, 2026 09:24
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.

2 participants