[CP] set is_cs_replica_compat in storage_schema respect column group array

This commit is contained in:
Tsunaou 2024-10-09 14:46:08 +00:00 committed by ob-robot
parent 337cc32617
commit 365850f8ef
4 changed files with 29 additions and 22 deletions

View File

@ -481,6 +481,7 @@ int ObStorageSchema::init(
ret = OB_ERR_UNEXPECTED;
STORAGE_LOG(ERROR, "storage schema is invalid", K(ret));
} else {
is_cs_replica_compat_ = is_cg_array_generated_in_cs_replica();
is_inited_ = true;
}
@ -554,6 +555,7 @@ int ObStorageSchema::init(
ret = OB_ERR_UNEXPECTED;
STORAGE_LOG(ERROR, "storage schema is invalid", K(ret));
} else {
is_cs_replica_compat_ = is_cg_array_generated_in_cs_replica();
is_inited_ = true;
}
}
@ -1148,6 +1150,7 @@ int ObStorageSchema::generate_cs_replica_cg_array()
if (OB_FAIL(generate_cs_replica_cg_array(*allocator_, column_group_array_))) {
STORAGE_LOG(WARN, "Failed to generate column store cg array", K(ret), KPC(this));
} else {
is_cs_replica_compat_ = is_cg_array_generated_in_cs_replica();
STORAGE_LOG(INFO, "[CS-Replica] Success to generate cs replica cg array", K(ret), KPC(this));
}
return ret;
@ -1325,13 +1328,13 @@ int ObStorageSchema::get_column_group_index(
return ret;
}
bool ObStorageSchema::is_cs_replica_compat() const
bool ObStorageSchema::is_cg_array_generated_in_cs_replica() const
{
bool bret = false;
if (column_group_array_.count() <= 1) {
// row store
} else {
bret = column_group_array_.at(0).is_rowkey_column_group();
bret = column_group_array_.at(0).is_rowkey_column_group(); // only cs replica set rowkey cg in the front of cg array
}
return bret;
}

View File

@ -297,6 +297,7 @@ public:
const uint64_t &column_id,
const int32_t &column_idx,
int32_t &cg_idx) const;
bool is_cg_array_generated_in_cs_replica() const;
// Use this comparison function to determine which schema has been updated later
// true: input_schema is newer
// false: current schema is newer
@ -309,11 +310,11 @@ public:
inline bool is_aux_lob_meta_table() const { return share::schema::is_aux_lob_meta_table(table_type_); }
inline bool is_aux_lob_piece_table() const { return share::schema::is_aux_lob_piece_table(table_type_); }
OB_INLINE bool is_user_hidden_table() const { return share::schema::TABLE_STATE_IS_HIDDEN_MASK & table_mode_.state_flag_; }
bool is_cs_replica_compat() const; // tmp
OB_INLINE bool is_cs_replica_compat() const { return is_cs_replica_compat_; }
VIRTUAL_TO_STRING_KV(KP(this), K_(storage_schema_version), K_(version),
K_(is_use_bloomfilter), K_(column_info_simplified), K_(compat_mode), K_(table_type), K_(index_type),
K_(row_store_type), K_(schema_version),
K_(row_store_type), K_(schema_version), K_(is_cs_replica_compat),
K_(column_cnt), K_(store_column_cnt), K_(tablet_size), K_(pctfree), K_(block_size), K_(progressive_merge_round),
K_(master_key_id), K_(compressor_type), K_(encryption), K_(encrypt_key),
"rowkey_cnt", rowkey_array_.count(), K_(rowkey_array), "column_cnt", column_array_.count(), K_(column_array),
@ -362,7 +363,7 @@ public:
static const int32_t SS_ONE_BIT = 1;
static const int32_t SS_HALF_BYTE = 4;
static const int32_t SS_ONE_BYTE = 8;
static const int32_t SS_RESERVED_BITS = 18;
static const int32_t SS_RESERVED_BITS = 17;
// STORAGE_SCHEMA_VERSION is for serde compatibility.
// Currently we do not use "standard" serde function macro,
@ -386,6 +387,7 @@ public:
uint32_t compat_mode_ :SS_HALF_BYTE;
uint32_t is_use_bloomfilter_ :SS_ONE_BIT;
uint32_t column_info_simplified_ :SS_ONE_BIT;
uint32_t is_cs_replica_compat_ :SS_ONE_BIT; // for storage schema on tablet
uint32_t reserved_ :SS_RESERVED_BITS;
};
};

View File

@ -405,7 +405,7 @@ int ObTablet::init_for_first_time_creation(
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else if (OB_FAIL(check_sstable_column_checksum())) {
LOG_WARN("failed to check sstable column checksum", K(ret), KPC(this));
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, need_generate_cs_replica_cg_array))) {
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("failed to build read info", K(ret));
} else if (OB_FAIL(init_aggregated_info(allocator, nullptr/* link_writer, tmp_tablet do no write */))) {
LOG_WARN("fail to init aggregated info", K(ret));
@ -491,7 +491,7 @@ int ObTablet::init_for_merge(
if (FAILEDx(table_store_cache_.init(table_store_addr_.get_ptr()->get_major_sstables(),
table_store_addr_.get_ptr()->get_minor_sstables(),
param.storage_schema_->is_row_store()))) {
storage_schema_addr_.get_ptr()->is_row_store()))) {
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else if (OB_FAIL(try_update_start_scn())) {
LOG_WARN("failed to update start scn", K(ret), K(param), K(table_store_addr_));
@ -504,7 +504,7 @@ int ObTablet::init_for_merge(
}
if (OB_FAIL(ret)) {
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, is_convert_co_merge ? true : old_tablet.is_cs_replica_compat()))) {
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("failed to build read info", K(ret));
} else if (OB_FAIL(check_medium_list())) {
LOG_WARN("failed to check medium list", K(ret), K(param), K(old_tablet));
@ -755,9 +755,9 @@ int ObTablet::init_with_migrate_param(
if (OB_FAIL(ret)) {
} else if (OB_FAIL(table_store_cache_.init(table_store_addr_.get_ptr()->get_major_sstables(),
table_store_addr_.get_ptr()->get_minor_sstables(),
param.storage_schema_.is_row_store() && !need_process_cs_replica))) {
storage_schema_addr_.get_ptr()->is_row_store()))) {
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, need_process_cs_replica || param.is_storage_schema_cs_replica_))) {
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("fail to build read info", K(ret));
} else if (OB_FAIL(check_medium_list())) {
LOG_WARN("failed to check medium list", K(ret), K(param));
@ -831,7 +831,7 @@ int ObTablet::init_for_defragment(
}
if (OB_FAIL(ret)) {
} else if (OB_FAIL(build_read_info(*allocator_, nullptr /*tablet*/, old_tablet.is_cs_replica_compat()))) {
} else if (OB_FAIL(build_read_info(*allocator_, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("fail to build read info", K(ret));
} else if (OB_FAIL(check_medium_list())) {
LOG_WARN("failed to check medium list", K(ret), KPC(this));
@ -954,14 +954,14 @@ int ObTablet::init_for_sstable_replace(
LOG_ERROR("find error while checking tablet schema mismatch", K(ret), KPC(storage_schema), K(old_tablet));
} else if (OB_FAIL(table_store_cache_.init(table_store_addr_.get_ptr()->get_major_sstables(),
table_store_addr_.get_ptr()->get_minor_sstables(),
storage_schema->is_row_store()))) {
storage_schema_addr_.get_ptr()->is_row_store()))) {
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else if (FALSE_IT(finish_medium_scn = get_last_major_snapshot_version())) {
} else if (nullptr != param.tablet_meta_ && FALSE_IT(tablet_meta_.update_extra_medium_info(
old_tablet.tablet_meta_.extra_medium_info_, param.tablet_meta_->extra_medium_info_, finish_medium_scn))) {
} else if (!is_ls_inner_tablet() && !param.is_transfer_replace_ && !is_tablet_split && OB_FAIL(update_tablet_status_from_sstable(false/*expect_persist_status*/))) {
LOG_WARN("fail to update tablet status from sstable", K(ret));
} else if (OB_FAIL(build_read_info(*allocator_, nullptr /*tablet*/, old_tablet.is_cs_replica_compat() || param_is_storage_schema_cs_replica))) {
} else if (OB_FAIL(build_read_info(*allocator_, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("failed to build read info", K(ret));
} else if (OB_FAIL(check_medium_list())) {
LOG_WARN("failed to check medium list", K(ret), K(param), K(old_tablet));
@ -1229,7 +1229,7 @@ int ObTablet::init_with_update_medium_info(
} else {
ALLOC_AND_INIT(allocator, storage_schema_addr_, *old_storage_schema);
if (OB_FAIL(ret)) {
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, old_tablet.is_cs_replica_compat()))) {
} else if (OB_FAIL(build_read_info(allocator, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("failed to build read info", K(ret));
} else {
if (old_tablet.get_tablet_meta().has_next_tablet_) {
@ -1393,10 +1393,6 @@ int ObTablet::init_with_replace_members(
LOG_WARN("fail to copy table store", K(ret), KPC(old_table_store));
} else if (OB_FAIL(try_update_start_scn())) {
LOG_WARN("failed to update start scn", K(ret), KPC(old_table_store));
} else if (OB_FAIL(table_store_cache_.init(table_store_addr_.get_ptr()->get_major_sstables(),
table_store_addr_.get_ptr()->get_minor_sstables(),
need_generate_cs_replica_cg_array ? false /*is_row_store*/ : old_tablet.table_store_cache_.is_row_store_))) {
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else if (OB_FAIL(init_aggregated_info(allocator, nullptr/* link_writer, tmp_tablet do no write */))) {
LOG_WARN("fail to init aggregated info", K(ret));
} else if (FALSE_IT(set_initial_addr())) {
@ -1415,8 +1411,12 @@ int ObTablet::init_with_replace_members(
ALLOC_AND_INIT(allocator, storage_schema_addr_, *old_storage_schema);
}
if (FAILEDx(build_read_info(allocator, nullptr /*tablet*/, need_generate_cs_replica_cg_array ? true : old_tablet.is_cs_replica_compat()))) {
if (FAILEDx(build_read_info(allocator, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("failed to build read info", K(ret));
} else if (OB_FAIL(table_store_cache_.init(table_store_addr_.get_ptr()->get_major_sstables(),
table_store_addr_.get_ptr()->get_minor_sstables(),
storage_schema_addr_.get_ptr()->is_row_store()))) {
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else {
if (old_tablet.get_tablet_meta().has_next_tablet_) {
set_next_tablet_guard(old_tablet.next_tablet_guard_);
@ -1490,7 +1490,7 @@ int ObTablet::init_with_mds_sstable(
table_store_addr_.get_ptr()->get_minor_sstables(),
old_tablet.table_store_cache_.is_row_store_))) {
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else if (CLICK() && FAILEDx(build_read_info(*allocator_, nullptr /*tablet*/, old_tablet.is_cs_replica_compat()))) {
} else if (CLICK() && FAILEDx(build_read_info(*allocator_, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("failed to build read info", K(ret));
} else if (CLICK_FAIL(check_medium_list())) {
LOG_WARN("failed to check medium list", K(ret), KPC(this));
@ -1671,7 +1671,7 @@ int ObTablet::inner_init_compat_normal_tablet(
table_store_addr_.get_ptr()->get_minor_sstables(),
old_tablet.table_store_cache_.is_row_store_))) {
LOG_WARN("failed to init table store cache", K(ret), KPC(this));
} else if (CLICK_FAIL(build_read_info(*allocator_, nullptr /*tablet*/, old_tablet.is_cs_replica_compat()))) {
} else if (CLICK_FAIL(build_read_info(*allocator_, nullptr /*tablet*/, storage_schema_addr_.get_ptr()->is_cs_replica_compat()))) {
LOG_WARN("failed to build read info", K(ret));
} else if (CLICK_FAIL(check_medium_list())) {
LOG_WARN("failed to check medium list", K(ret), KPC(this));
@ -5369,7 +5369,8 @@ int ObTablet::build_read_info(
tablet = (tablet == nullptr) ? this : tablet;
if (OB_FAIL(tablet->load_storage_schema(allocator, storage_schema))) {
LOG_WARN("fail to load storage schema", K(ret));
} else if (OB_UNLIKELY(storage_schema->is_row_store() && is_cs_replica_compat)) {
} else if (OB_UNLIKELY((storage_schema->is_row_store() && is_cs_replica_compat)
|| (storage_schema->is_cg_array_generated_in_cs_replica() && !is_cs_replica_compat))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("mismatch storage schema and cs replica param", K(ret), KPC(storage_schema), K(is_cs_replica_compat));
} else if (OB_FAIL(storage_schema->get_mulit_version_rowkey_column_ids(cols_desc))) {

View File

@ -1731,6 +1731,7 @@ int ObMigrationTabletParam::construct_placeholder_storage_schema_and_medium(
storage_schema.progressive_merge_num_ = 0;
storage_schema.master_key_id_ = OB_INVALID_ID;
storage_schema.compat_mode_ = static_cast<uint32_t>(lib::Worker::get_compatibility_mode());
storage_schema.is_cs_replica_compat_ = false;
ObStorageRowkeyColumnSchema rowkey_schema;
rowkey_schema.meta_type_.set_tinyint();