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

feat: impl migrate_region and procedure_state SQL function #3325

Merged
merged 13 commits into from
Feb 22, 2024

Conversation

killme2008
Copy link
Contributor

@killme2008 killme2008 commented Feb 19, 2024

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

It's the following PR of #3236 and #3278 .

Improves:

  • Fetching partition and region distribution in batch for information_schema tables.

Implements:

  • migrate_region(region_id, from_peer, to_peer, [timeout]) to migrate region betweeen datanodes.
  • procedure_state(procedure_id) to query procedure state.

Note: for security reasons, these two functions only can be called under the greptime catalog.

For example:

  1. Query the region distribution by SQL:
select b.peer_id as datanode_id,
       a.greptime_partition_id as region_id
from information_schema.partitions a left join information_schema.greptime_region_peers b
on a.greptime_partition_id = b.region_id
where a.table_name='migration_target' order by datanode_id asc

The SQL finds the datanode peer id and region id by table name.

  1. Migrate the region via:
select migrate_region(4398046511104, 1, 2)

It will return the procedure id such as 538b7476-9f79-4e50-aa9c-b1de90710839.

  1. Query the procedure state via:
select procedure_state('538b7476-9f79-4e50-aa9c-b1de90710839')

It will return the procedure state in JSON

 {"status":"Done"}

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

Refer to a related PR or issue link (optional)

#2931 #3161 #2921

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Feb 19, 2024
@waynexia waynexia changed the title feat:impl migrate_region function feat: impl migrate_region function Feb 20, 2024
@killme2008 killme2008 changed the title feat: impl migrate_region function feat: impl migrate_region and procedure_state SQL function Feb 20, 2024
@killme2008 killme2008 marked this pull request as ready for review February 21, 2024 03:47
@github-actions github-actions bot added docs-required This change requires docs update. and removed docs-not-required This change does not impact docs. labels Feb 21, 2024
@killme2008 killme2008 added C-enhancement Category Enhancements C-feature Category Features C-user-experience Category User Experience labels Feb 21, 2024
Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: 74 lines in your changes are missing coverage. Please review.

Comparison is base (41656c8) 85.28% compared to head (9068098) 85.25%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3325      +/-   ##
==========================================
- Coverage   85.28%   85.25%   -0.03%     
==========================================
  Files         884      886       +2     
  Lines      144256   144589     +333     
==========================================
+ Hits       123028   123270     +242     
- Misses      21228    21319      +91     

Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

LGTM

@WenyXu
Copy link
Member

WenyXu commented Feb 22, 2024

Just to confirm, is the unit of the timeout(the arguments in the migrate_region) in seconds?

@killme2008
Copy link
Contributor Author

Just to confirm, is the unit of the timeout(the arguments in the migrate_region) in seconds?

Yes, I think seconds unit is enough.

@killme2008 killme2008 added this pull request to the merge queue Feb 22, 2024
Merged via the queue into GreptimeTeam:main with commit 564fe3b Feb 22, 2024
19 checks passed
@killme2008 killme2008 deleted the feature/migrate-region-part-2 branch February 22, 2024 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements C-feature Category Features C-user-experience Category User Experience docs-required This change requires docs update.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants