Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix the bug of direct schema change (backport #44854) #44941

Merged
merged 7 commits into from
May 1, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Apr 29, 2024

Why I'm doing:

If the segments of single rowset is overlapping, will should use heap merge when do direct schema change, otherwise the rows is not ordered by sort key.

How to reproduce:

 CREATE TABLE `lineorder_1` (
  `lo_orderkey` int(11) NOT NULL COMMENT "",
  `lo_linenumber` int(11) NOT NULL COMMENT "",
  `lo_custkey` int(11) NOT NULL COMMENT "",
  `lo_partkey` int(11) NOT NULL COMMENT "",
  `lo_suppkey` int(11) NOT NULL COMMENT "",
  `lo_orderdate` int(11) NOT NULL COMMENT "",
  `lo_orderpriority` varchar(16) NOT NULL COMMENT "",
  `lo_shippriority` int(11) NOT NULL COMMENT "",
  `lo_quantity` int(11) NOT NULL COMMENT "",
  `lo_extendedprice` int(11) NOT NULL COMMENT "",
  `lo_ordtotalprice` int(11) NOT NULL COMMENT "",
  `lo_discount` int(11) NOT NULL COMMENT "",
  `lo_revenue` int(11) NOT NULL COMMENT "",
  `lo_supplycost` int(11) NOT NULL COMMENT "",
  `lo_tax` int(11) NOT NULL COMMENT "",
  `lo_commitdate` int(11) NOT NULL COMMENT "",
  `lo_shipmode` varchar(11) NOT NULL COMMENT "",
  INDEX t1 (`lo_partkey`) USING BITMAP COMMENT ''
) ENGINE=OLAP 
DUPLICATE KEY(`lo_orderkey`, `lo_linenumber`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 1 
PROPERTIES (
"compression" = "LZ4",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "1"
);

insert into lineorder_1 select * from lineorder limit 2000000;

select * from lineorder_1 where lo_orderkey>5427812 and lo_orderkey<=5927812;
select lo_orderkey from lineorder_1 where lo_orderkey>5427812 and lo_orderkey<=5927812;
 
The num of return rows is inconsistent.

What I'm doing:

Use heap merge for direct schema change if the segments of rwoset is overlapping.

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
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

This is an automatic backport of pull request #44854 done by [Mergify](https://mergify.com). ## Why I'm doing:

If the segments of single rowset is overlapping, will should use heap merge when do direct schema change, otherwise the rows is not ordered by sort key.

How to reproduce:

 CREATE TABLE `lineorder_1` (
  `lo_orderkey` int(11) NOT NULL COMMENT "",
  `lo_linenumber` int(11) NOT NULL COMMENT "",
  `lo_custkey` int(11) NOT NULL COMMENT "",
  `lo_partkey` int(11) NOT NULL COMMENT "",
  `lo_suppkey` int(11) NOT NULL COMMENT "",
  `lo_orderdate` int(11) NOT NULL COMMENT "",
  `lo_orderpriority` varchar(16) NOT NULL COMMENT "",
  `lo_shippriority` int(11) NOT NULL COMMENT "",
  `lo_quantity` int(11) NOT NULL COMMENT "",
  `lo_extendedprice` int(11) NOT NULL COMMENT "",
  `lo_ordtotalprice` int(11) NOT NULL COMMENT "",
  `lo_discount` int(11) NOT NULL COMMENT "",
  `lo_revenue` int(11) NOT NULL COMMENT "",
  `lo_supplycost` int(11) NOT NULL COMMENT "",
  `lo_tax` int(11) NOT NULL COMMENT "",
  `lo_commitdate` int(11) NOT NULL COMMENT "",
  `lo_shipmode` varchar(11) NOT NULL COMMENT "",
  INDEX t1 (`lo_partkey`) USING BITMAP COMMENT ''
) ENGINE=OLAP 
DUPLICATE KEY(`lo_orderkey`, `lo_linenumber`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 1 
PROPERTIES (
"compression" = "LZ4",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "1"
);

insert into lineorder_1 select * from lineorder limit 2000000;

select * from lineorder_1 where lo_orderkey>5427812 and lo_orderkey<=5927812;
select lo_orderkey from lineorder_1 where lo_orderkey>5427812 and lo_orderkey<=5927812;
 
The num of return rows is inconsistent.

What I'm doing:

Use heap merge for direct schema change if the segments of rwoset is overlapping.

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

Signed-off-by: trueeyu <lxhhust350@qq.com>
(cherry picked from commit 301445d)

# Conflicts:
#	be/src/storage/schema_change.cpp
#	be/src/storage/segment_replicate_executor.h
#	be/src/storage/task/engine_alter_tablet_task.cpp
#	be/src/testutil/CMakeLists.txt
#	be/test/storage/schema_change_test.cpp
#	be/test/storage/tablet_updates_schema_change_test.cpp
@mergify mergify bot added the conflicts label Apr 29, 2024
Copy link
Contributor Author

mergify bot commented Apr 29, 2024

Cherry-pick of 301445d has failed:

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

You are currently cherry-picking commit 301445d9fc.
  (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/schema_change.h
	new file:   be/src/testutil/schema_test_helper.cpp
	new file:   be/src/testutil/schema_test_helper.h
	new file:   be/src/testutil/tablet_test_helper.cpp
	new file:   be/src/testutil/tablet_test_helper.h

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   be/src/storage/schema_change.cpp
	both modified:   be/src/storage/segment_replicate_executor.h
	both modified:   be/src/storage/task/engine_alter_tablet_task.cpp
	both modified:   be/src/testutil/CMakeLists.txt
	both modified:   be/test/storage/schema_change_test.cpp
	deleted by us:   be/test/storage/tablet_updates_schema_change_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

@wanpengfei-git wanpengfei-git enabled auto-merge (squash) April 29, 2024 02:29
@mergify mergify bot closed this Apr 29, 2024
auto-merge was automatically disabled April 29, 2024 02:29

Pull request was closed

Copy link
Contributor Author

mergify bot commented Apr 29, 2024

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@mergify mergify bot deleted the mergify/bp/branch-2.5/pr-44854 branch April 29, 2024 02:30
@trueeyu trueeyu restored the mergify/bp/branch-2.5/pr-44854 branch April 30, 2024 11:42
@trueeyu trueeyu reopened this Apr 30, 2024
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) April 30, 2024 11:43
Signed-off-by: trueeyu <lxhhust350@qq.com>
Signed-off-by: trueeyu <lxhhust350@qq.com>
Signed-off-by: trueeyu <lxhhust350@qq.com>
Signed-off-by: trueeyu <lxhhust350@qq.com>
Signed-off-by: trueeyu <lxhhust350@qq.com>
Signed-off-by: trueeyu <lxhhust350@qq.com>
@wanpengfei-git wanpengfei-git merged commit 2ea2481 into branch-2.5 May 1, 2024
27 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-2.5/pr-44854 branch May 1, 2024 02:53
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.

None yet

2 participants