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

[Feature] Support pk table migration (#25521) #25522

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

srlch
Copy link
Contributor

@srlch srlch commented Jun 19, 2023

Support primary key table disk migration

Fixes #25521

What type of PR is this:

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

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr will affect users' behaviors
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.1
    • 3.0
    • 2.5
    • 2.4

@mergify mergify bot assigned srlch Jun 19, 2023
@srlch srlch force-pushed the feature_support_pk_migration branch 4 times, most recently from fc2126d to 5a47004 Compare July 11, 2023 08:42
nshangyiming
nshangyiming previously approved these changes Jul 12, 2023
Copy link
Contributor

@nshangyiming nshangyiming left a comment

Choose a reason for hiding this comment

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

I have reviewed the FE part, for BE part, plz ask @decster @chaoyli for review

@nshangyiming nshangyiming enabled auto-merge (squash) July 12, 2023 02:37
auto-merge was automatically disabled July 12, 2023 02:42

Head branch was pushed to by a user without write access

@srlch srlch force-pushed the feature_support_pk_migration branch from 5a47004 to f4ef300 Compare July 12, 2023 02:42
nshangyiming
nshangyiming previously approved these changes Jul 12, 2023
@srlch srlch force-pushed the feature_support_pk_migration branch 5 times, most recently from 83e3d2d to 79c49f6 Compare July 19, 2023 10:26
Comment on lines 991 to 1048
db.readLock();
try {
OlapTable table = (OlapTable) db.getTable(tabletMeta.getTableId());
if (table.getKeysType() == KeysType.PRIMARY_KEYS) {
// Currently, primary key table doesn't support tablet migration between local disks.
continue;
}
} finally {
db.readUnlock();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

987-996 lines can be removed

@@ -631,7 +631,7 @@ public boolean needSchedule(boolean isLocalBalance) {
}

OlapTable olapTable = (OlapTable) this;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
OlapTable olapTable = (OlapTable) this;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -116,7 +117,9 @@ Status TabletManager::_add_tablet_unlocked(const TabletSharedPtr& new_tablet, bo
auto new_version = (new_rowset == nullptr) ? -1 : new_rowset->end_version();
old_tablet->release_header_lock();
bool replace_old = (new_version > old_version) || (new_version == old_version && new_time > old_time);
if (replace_old) {
// In case of pk table migration, version and rowset can not be acquired by
// the above api. We may need to force to replace the old tablet in this case by kMoveFilesToTrash mode
Copy link
Contributor

Choose a reason for hiding this comment

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

use pk api to check? better to keep version and time check for safety

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@srlch srlch force-pushed the feature_support_pk_migration branch 6 times, most recently from cc07bf4 to 33aa5f9 Compare August 9, 2023 06:44
@srlch srlch force-pushed the feature_support_pk_migration branch 5 times, most recently from 498df63 to 0905216 Compare August 11, 2023 07:28
@srlch srlch force-pushed the feature_support_pk_migration branch from b92a0c6 to 0fa6284 Compare August 16, 2023 02:19
gengjun-git
gengjun-git previously approved these changes Aug 16, 2023
@srlch srlch force-pushed the feature_support_pk_migration branch 4 times, most recently from eb390b3 to 8df3252 Compare August 18, 2023 05:03
@wanpengfei-git
Copy link
Collaborator

[FE PR Coverage Check]

😍 pass : 63 / 72 (87.50%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/clone/TabletScheduler.java 21 27 77.78% [1383, 1384, 1393, 1394, 1395, 1397]
🔵 com/starrocks/catalog/Replica.java 5 6 83.33% [343]
🔵 com/starrocks/leader/ReportHandler.java 32 34 94.12% [1003, 1039]
🔵 com/starrocks/catalog/Table.java 1 1 100.00% []
🔵 com/starrocks/common/Config.java 1 1 100.00% []
🔵 com/starrocks/server/LocalMetastore.java 1 1 100.00% []
🔵 com/starrocks/catalog/TabletInvertedIndex.java 2 2 100.00% []

@srlch srlch force-pushed the feature_support_pk_migration branch from 8df3252 to 4c2c05b Compare August 21, 2023 06:53
@wanpengfei-git
Copy link
Collaborator

[null Incremental Coverage Report]

😞 fail : 46 / 72 (63.89%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/clone/TabletScheduler.java 5 27 18.52% [1363, 1364, 1365, 1366, 1367, 1369, 1370, 1371, 1374, 1375, 1377, 1379, 1382, 1383, 1384, 1387, 1389, 1390, 1393, 1394, 1395, 1397]
🔵 com/starrocks/catalog/TabletInvertedIndex.java 1 2 50.00% [176]
🔵 com/starrocks/catalog/Replica.java 5 6 83.33% [343]
🔵 com/starrocks/leader/ReportHandler.java 32 34 94.12% [1003, 1039]
🔵 com/starrocks/catalog/Table.java 1 1 100.00% []
🔵 com/starrocks/common/Config.java 1 1 100.00% []
🔵 com/starrocks/server/LocalMetastore.java 1 1 100.00% []

@srlch srlch force-pushed the feature_support_pk_migration branch 4 times, most recently from 4196f0a to 9779913 Compare August 22, 2023 03:16
chaoyli
chaoyli previously approved these changes Aug 22, 2023
@srlch srlch force-pushed the feature_support_pk_migration branch 3 times, most recently from 8f78ded to 1170cba Compare August 22, 2023 06:05
Signed-off-by: srlch <linzichao@starrocks.com>
@srlch srlch force-pushed the feature_support_pk_migration branch from 1170cba to 45b9e2d Compare August 22, 2023 07:24
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell D 56 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.20) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@wanpengfei-git
Copy link
Collaborator

[FE Incremental Coverage Report]

😍 pass : 63 / 72 (87.50%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/clone/TabletScheduler.java 21 27 77.78% [1383, 1384, 1393, 1394, 1395, 1397]
🔵 com/starrocks/catalog/Replica.java 5 6 83.33% [343]
🔵 com/starrocks/leader/ReportHandler.java 32 34 94.12% [1004, 1040]
🔵 com/starrocks/catalog/Table.java 1 1 100.00% []
🔵 com/starrocks/common/Config.java 1 1 100.00% []
🔵 com/starrocks/server/LocalMetastore.java 1 1 100.00% []
🔵 com/starrocks/catalog/TabletInvertedIndex.java 2 2 100.00% []

@wanpengfei-git
Copy link
Collaborator

[BE Incremental Coverage Report]

😞 fail : 88 / 144 (61.11%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 src/storage/storage_engine.cpp 0 5 00.00% [950, 951, 952, 954, 955]
🔵 src/storage/task/engine_storage_migration_task.cpp 48 93 51.61% [117, 118, 119, 120, 129, 130, 131, 132, 235, 236, 237, 238, 239, 240, 273, 274, 281, 282, 287, 288, 289, 290, 499, 500, 501, 502, 503, 504, 505, 517, 518, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 553, 554, 555]
🔵 src/storage/tablet_updates.cpp 17 21 80.95% [2737, 4588, 4589, 4606]
🔵 src/storage/tablet_manager.cpp 22 24 91.67% [1527, 1528]
🔵 src/storage/snapshot_manager.cpp 1 1 100.00% []

@chaoyli chaoyli merged commit 1341138 into StarRocks:main Aug 22, 2023
Jay-ju pushed a commit to Jay-ju/starrocks that referenced this pull request Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Support pk table migration
6 participants