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
*: add a procedure that upgrades data from v2 to v3 #4381
Conversation
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
/run-integration-tests |
LGTM |
src/raftstore/store/keys.rs
Outdated
pub fn decode_region_meta_key(key: &[u8]) -> Result<(u64, u8)> { | ||
if REGION_META_PREFIX_KEY.len() + mem::size_of::<u64>() + mem::size_of::<u8>() != key.len() { | ||
/// Decode region key, return the region id and meta suffix type. | ||
fn decode_region_key(prefix: &[u8], key: &[u8], which: &str) -> Result<(u64, u8)> { |
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.
You mean category?
Signed-off-by: Neil Shen <overvenus@gmail.com>
src/raftstore/store/peer_storage.rs
Outdated
// Create v2.0.x kv engine. | ||
let kv_cfs_opts = kv_cfg.build_cf_opts_v2(); | ||
let mut kv_engine = util::rocksdb_util::new_engine_opt(kv_path, kv_db_opts, kv_cfs_opts) | ||
.unwrap_or_else(|s| panic!("failed to create kv engine: {}", s)); |
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.
Better return error and let outside to decide to panic or fatal.
src/raftstore/store/keys.rs
Outdated
pub fn decode_region_meta_key(key: &[u8]) -> Result<(u64, u8)> { | ||
if REGION_META_PREFIX_KEY.len() + mem::size_of::<u64>() + mem::size_of::<u8>() != key.len() { | ||
/// Decode region category key, return the region id and meta suffix type. | ||
fn decode_region_category_key(prefix: &[u8], key: &[u8], which: &str) -> Result<(u64, u8)> { |
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.
Oh, what I mean is which
is meaningless without context.
Signed-off-by: Neil Shen <overvenus@gmail.com>
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
src/raftstore/store/peer_storage.rs
Outdated
} else if let Ok((region_id, suffix)) = keys::decode_region_meta_key(key) { | ||
if suffix == keys::REGION_STATE_SUFFIX { | ||
upgrade_raft_wb.put(key, value)?; | ||
info!("upgrading region state"; "region_id" => region_id, "value" => ?value); |
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.
Seems too verbose.
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
What have you changed? (mandatory)
In v3.x, we move all meta data to raft engine and remove RAFT CF of kv engine. This is a precede change of #4372 , it add a procedure that upgrades data from v2 to v3:
What are the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
Unit tests and integration tests, however integration tests can not run with out full change of #4372 .
Does this PR affect documentation (docs) update? (mandatory)
No.
Does this PR affect tidb-ansible update? (mandatory)
No.
Refer to a related PR or issue link (optional)
#4372