[CP] fix direct load data in cs replica

This commit is contained in:
Tsunaou 2024-10-08 15:45:32 +00:00 committed by ob-robot
parent a92b7ae7cf
commit 1e4b1b8de4
4 changed files with 33 additions and 5 deletions

View File

@ -2432,7 +2432,7 @@ int ObTabletFullDirectLoadMgr::update(
if (OB_ISNULL(sqc_build_ctx_.storage_schema_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("null storage schema", K(ret));
} else if (OB_FAIL(ObCODDLUtil::need_column_group_store(*sqc_build_ctx_.storage_schema_, is_column_group_store))) {
} else if (OB_FAIL(check_need_replay_column_store(*sqc_build_ctx_.storage_schema_, build_param.common_param_.direct_load_type_, is_column_group_store))) {
LOG_WARN("fail to get schema is column group store", K(ret));
} else if (is_column_group_store && !replay_normal_in_cs_replica) {
table_key_.table_type_ = ObITable::COLUMN_ORIENTED_SSTABLE;
@ -3229,7 +3229,7 @@ int ObTabletFullDirectLoadMgr::init_ddl_table_store(
LOG_WARN("get tablet handle failed", K(ret), K(ls_id_), K(tablet_id_));
} else if (OB_FAIL(tablet_handle.get_obj()->load_storage_schema(tmp_arena, storage_schema))) {
LOG_WARN("failed to load storage schema", K(ret), K(tablet_handle));
} else if (OB_FAIL(ObCODDLUtil::need_column_group_store(*storage_schema, is_column_group_store))) {
} else if (OB_FAIL(check_need_replay_column_store(*storage_schema, direct_load_type_, is_column_group_store))) {
LOG_WARN("fail to check schema is column group store", K(ret));
} else if (OB_ISNULL(ls = ls_handle.get_ls())) {
ret = OB_ERR_UNEXPECTED;
@ -3301,13 +3301,10 @@ int ObTabletFullDirectLoadMgr::init_ddl_table_store(
}
}
}
bool is_column_group_store = false;
if (OB_FAIL(ret)) {
} else if (FALSE_IT(param.sstable_ = static_cast<ObSSTable *>(sstable_handle.get_table()))) {
} else if (OB_FAIL(ls_handle.get_ls()->update_tablet_table_store(tablet_id_, param, new_tablet_handle))) {
LOG_WARN("failed to update tablet table store", K(ret), K(ls_id_), K(tablet_id_), K(param));
} else if (OB_FAIL(ObCODDLUtil::need_column_group_store(*storage_schema, is_column_group_store))) {
LOG_WARN("failed to check storage schema is column group store", K(ret));
} else {
LOG_INFO("update tablet success", K(ls_id_), K(tablet_id_),
"is_column_store", is_column_group_store, K(ddl_param),
@ -3387,6 +3384,24 @@ int ObTabletFullDirectLoadMgr::pre_process_cs_replica(
return ret;
}
int ObTabletFullDirectLoadMgr::check_need_replay_column_store(
const ObStorageSchema &storage_schema,
const ObDirectLoadType &direct_load_type,
bool &need_replay_column_store)
{
int ret = OB_SUCCESS;
need_replay_column_store = false;
if (OB_FAIL(ObCODDLUtil::need_column_group_store(storage_schema, need_replay_column_store))) {
LOG_WARN("failed to check need replay column store", K(ret), K(storage_schema));
} else if (!is_ddl_direct_load(direct_load_type) && need_replay_column_store) {
// if table is row store in F-replica and local ls is cs replica, storage schema in tablet will be column store.
// but full direct load will not write column store redo log.
// so when full direct load, is storage schema is column store and cs replica compat, need replay row store.
need_replay_column_store = !storage_schema.is_cs_replica_compat();
}
return ret;
}
/**
* ObTabletIncDirectLoadMgr
*/

View File

@ -542,6 +542,7 @@ private:
int init_ddl_table_store(const share::SCN &start_scn, const int64_t snapshot_version, const share::SCN &ddl_checkpoint_scn);
int update_major_sstable();
int pre_process_cs_replica(const ObTabletID &tablet_id, bool &replay_normal_in_cs_replica);
int check_need_replay_column_store(const ObStorageSchema &storage_schema, const ObDirectLoadType &direct_load_type, bool &need_replay_column_store);
private:
share::SCN start_scn_;

View File

@ -1325,6 +1325,17 @@ int ObStorageSchema::get_column_group_index(
return ret;
}
bool ObStorageSchema::is_cs_replica_compat() const
{
bool bret = false;
if (column_group_array_.count() <= 1) {
// row store
} else {
bret = column_group_array_.at(0).is_rowkey_column_group();
}
return bret;
}
int ObStorageSchema::deserialize_column_group_array(ObIAllocator &allocator,
const char *buf,
const int64_t data_len,

View File

@ -309,6 +309,7 @@ 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
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),