-
Notifications
You must be signed in to change notification settings - Fork 390
feat: introduce reconcile table procedure #6584
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
base: main
Are you sure you want to change the base?
Conversation
e39bf15
to
5197994
Compare
Signed-off-by: WenyXu <wenymedia@gmail.com>
5197994
to
3201a4d
Compare
Signed-off-by: WenyXu <wenymedia@gmail.com>
3201a4d
to
f792ebf
Compare
@@ -140,7 +140,7 @@ etcd-client = "0.14" | |||
fst = "0.4.7" | |||
futures = "0.3" | |||
futures-util = "0.3" | |||
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "7fcaa3e413947a7a28d9af95812af26c1939ce78" } | |||
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "7be0563739721b69ff78686754c51d542c8fe8db" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait for GreptimeTeam/greptime-proto#261
let primary_key = | ||
new_primary_keys | ||
.get(name) | ||
.context(InvalidRegionRequestSnafu { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with_context
/// | ||
/// It will check the table id and table name consistency. | ||
/// If the table id and table name are not consistent, it will return an error. | ||
pub(crate) async fn validate_table_id_and_name( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why check this? In what situations would id and name be inconsistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
let new_primary_keys = column_metadatas | ||
.iter() | ||
.filter(|c| c.semantic_type == SemanticType::Tag) | ||
.map(|c| (c.column_schema.name.as_str(), c.column_id)) | ||
.collect::<HashMap<_, _>>(); | ||
|
||
let old_primary_keys = metadata | ||
.column_metadatas | ||
.iter() | ||
.filter(|c| c.semantic_type == SemanticType::Tag) | ||
.map(|c| (c.column_schema.name.as_str(), c.column_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primary keys may have a different order than the original column order.
We can create a table with columns (a, b, c) but primary key (c, a).
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
#6429
What's changed and what's your intention?
Introduce a procedure for reconciling table metadata between metasrv and datanode.
The reconciliation procedure implements a state machine pattern with the following states:
ReconciliationStart
: Validates table info and prepares for reconciliationResolveColumnMetadata
- resolve column metadata conflicts with configurable strategiesReconcileRegions
- Performs region reconciliation operationsUpdateTableInfo
- Update table info in metasrv if neededReconciliationEnd
PR Checklist
Please convert it to a draft if some of the following conditions are not met.