set ddl_table_type_ when creating tablet
This commit is contained in:
parent
21187ef944
commit
86af160b51
@ -272,7 +272,8 @@ int TestIndexBlockDataPrepare::gen_create_tablet_arg(const int64_t tenant_id,
|
||||
tablet_id,
|
||||
index_tablet_schema_idxs,
|
||||
lib::Worker::CompatMode::MYSQL,
|
||||
false))) {
|
||||
false,
|
||||
false /*has_cs_replica*/))) {
|
||||
STORAGE_LOG(WARN, "failed to init tablet info", KR(ret), K(index_tablet_ids),
|
||||
K(tablet_id), K(index_tablet_schema_idxs));
|
||||
} else if (OB_FAIL(arg.init_create_tablet(ls_id, share::SCN::min_scn(), false))) {
|
||||
|
@ -304,7 +304,7 @@ int TestDDLCreateTablet::build_create_tablet_arg(
|
||||
} else if (OB_FAIL(tablet_schema_index_array.push_back(0))) {
|
||||
STORAGE_LOG(WARN, "failed to push index into array", K(ret));
|
||||
} else if (OB_FAIL(tablet_info.init(tablet_id_array, data_tablet_id, tablet_schema_index_array,
|
||||
lib::get_compat_mode(), false/*is_create_bind_hidden_tablets*/))) {
|
||||
lib::get_compat_mode(), false/*is_create_bind_hidden_tablets*/, false /*has_cs_replica*/))) {
|
||||
STORAGE_LOG(WARN, "failed to init tablet info", K(ret), K(tablet_id_array),
|
||||
K(data_tablet_id), K(tablet_schema_index_array));
|
||||
} else if (OB_FAIL(arg.tablets_.push_back(tablet_info))) {
|
||||
|
@ -254,7 +254,7 @@ TEST_F(TestLSMigrationParam, test_migrate_tablet_param)
|
||||
scn.convert_from_ts(ObTimeUtility::current_time());
|
||||
ret = src_handle.get_obj()->init_for_first_time_creation(allocator_, src_key.ls_id_, src_key.tablet_id_, src_key.tablet_id_,
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/,
|
||||
true/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, ls_handle.get_ls()->get_freezer());
|
||||
true/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, ls_handle.get_ls()->get_freezer());
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
|
||||
share::SCN create_commit_scn;
|
||||
@ -339,7 +339,7 @@ TEST_F(TestLSMigrationParam, test_migration_param_compat)
|
||||
scn.convert_from_ts(ObTimeUtility::current_time());
|
||||
ret = src_handle.get_obj()->init_for_first_time_creation(allocator_, src_key.ls_id_, src_key.tablet_id_, src_key.tablet_id_,
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/,
|
||||
true/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, ls_handle.get_ls()->get_freezer());
|
||||
true/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, ls_handle.get_ls()->get_freezer());
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
|
||||
share::SCN create_commit_scn;
|
||||
|
@ -171,7 +171,7 @@ void TestLSTabletInfoWR::fill_tablet_meta()
|
||||
scn.convert_from_ts(ObTimeUtility::current_time());
|
||||
ret = src_handle.get_obj()->init_for_first_time_creation(arena_allocator_, src_key.ls_id_, src_key.tablet_id_, src_key.tablet_id_,
|
||||
scn, 2022, create_tablet_schema, true/*need_create_empty_major_sstable*/,
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, ls_handle.get_ls()->get_freezer());
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, ls_handle.get_ls()->get_freezer());
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
|
||||
share::SCN create_commit_scn;
|
||||
|
@ -724,7 +724,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_tablet)
|
||||
ObTabletID empty_tablet_id;
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema, true/*need_create_empty_major_sstable*/,
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
const ObTabletPersisterParam persist_param(ls_id_, ls_handle.get_ls()->get_ls_epoch(), tablet_id);
|
||||
@ -825,7 +825,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_inner_tablet)
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/,
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
@ -938,7 +938,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_no_sstable_tablet)
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/,
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
@ -1037,7 +1037,7 @@ TEST_F(TestTenantMetaMemMgr, test_get_tablet_with_allocator)
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/,
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
@ -1169,7 +1169,7 @@ TEST_F(TestTenantMetaMemMgr, test_wash_mem_tablet)
|
||||
ret = tablet->init_for_first_time_creation(allocator_, ls_id_, tablet_id, tablet_id,
|
||||
create_scn, create_scn.get_val_for_tx(), create_tablet_schema,
|
||||
make_empty_co_sstable/*need_create_empty_major_sstable*/,
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, &freezer);
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, &freezer);
|
||||
ASSERT_EQ(common::OB_SUCCESS, ret);
|
||||
ASSERT_EQ(1, tablet->get_ref());
|
||||
|
||||
|
@ -200,6 +200,7 @@ int ObTableCreator::add_create_tablets_of_tables_arg_(
|
||||
const common::ObIArray<bool> &need_create_empty_majors)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
const int64_t schema_cnt = schemas.count();
|
||||
if (OB_UNLIKELY(schema_cnt < 1 || tenant_data_version <= 0
|
||||
|| schema_cnt != need_create_empty_majors.count())) {
|
||||
@ -213,6 +214,7 @@ int ObTableCreator::add_create_tablets_of_tables_arg_(
|
||||
const share::schema::ObTableSchema &table_schema = *schemas.at(0);
|
||||
int64_t all_part_num = table_schema.get_all_part_num();
|
||||
common::ObArray<share::ObTabletTablePair> pairs;
|
||||
ObGlobalCSReplicaMgr cs_replica_mgr;
|
||||
bool is_oracle_mode = false;
|
||||
bool is_create_bind_hidden_tablets = false;
|
||||
if (table_schema.is_index_local_storage()
|
||||
@ -269,6 +271,11 @@ int ObTableCreator::add_create_tablets_of_tables_arg_(
|
||||
}
|
||||
}
|
||||
|
||||
// try init, but ignore ret. not blocking create tablet if query inner_table failed or other error
|
||||
if (OB_TMP_FAIL(cs_replica_mgr.try_init(tenant_id_, ls_id_array_))) {
|
||||
LOG_WARN("fail to init cs_replica_mgr", KR(tmp_ret));
|
||||
}
|
||||
|
||||
if (FAILEDx(data_table_schema->check_if_oracle_compat_mode(is_oracle_mode))) {
|
||||
LOG_WARN("fail to check oracle mode", KR(ret), KPC(data_table_schema));
|
||||
} else {
|
||||
@ -291,7 +298,8 @@ int ObTableCreator::add_create_tablets_of_tables_arg_(
|
||||
OB_INVALID_INDEX,
|
||||
is_create_bind_hidden_tablets,
|
||||
tenant_data_version,
|
||||
need_create_empty_majors))) {
|
||||
need_create_empty_majors,
|
||||
cs_replica_mgr))) {
|
||||
LOG_WARN("fail to generate_create_tablet_arg",
|
||||
K(table_schema), K(schemas), KR(ret), K(is_create_bind_hidden_tablets));
|
||||
}
|
||||
@ -317,7 +325,8 @@ int ObTableCreator::add_create_tablets_of_tables_arg_(
|
||||
OB_INVALID_INDEX,
|
||||
is_create_bind_hidden_tablets,
|
||||
tenant_data_version,
|
||||
need_create_empty_majors))) {
|
||||
need_create_empty_majors,
|
||||
cs_replica_mgr))) {
|
||||
LOG_WARN("fail to generate_create_tablet_arg",
|
||||
K(table_schema), K(schemas), KR(ret), K(i), K(is_create_bind_hidden_tablets));
|
||||
}
|
||||
@ -343,7 +352,8 @@ int ObTableCreator::add_create_tablets_of_tables_arg_(
|
||||
j,
|
||||
is_create_bind_hidden_tablets,
|
||||
tenant_data_version,
|
||||
need_create_empty_majors))) {
|
||||
need_create_empty_majors,
|
||||
cs_replica_mgr))) {
|
||||
LOG_WARN("fail to generate_create_tablet_arg",
|
||||
K(table_schema), K(schemas), KR(ret), K(i), K(j), K(is_create_bind_hidden_tablets));
|
||||
}
|
||||
@ -384,7 +394,8 @@ int ObTableCreator::generate_create_tablet_arg_(
|
||||
const int64_t subpart_idx,
|
||||
const bool is_create_bind_hidden_tablets,
|
||||
const uint64_t tenant_data_version,
|
||||
const common::ObIArray<bool> &need_create_empty_majors)
|
||||
const common::ObIArray<bool> &need_create_empty_majors,
|
||||
const ObGlobalCSReplicaMgr &cs_replica_mgr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTabletID data_tablet_id;
|
||||
@ -393,6 +404,7 @@ int ObTableCreator::generate_create_tablet_arg_(
|
||||
ObTabletID tablet_id;
|
||||
ObBasePartition *data_part = NULL;
|
||||
ObBasePartition *part = NULL;
|
||||
bool is_cs_replica_global_visible = false;
|
||||
if (PARTITION_LEVEL_ZERO == data_table_schema.get_part_level()) {
|
||||
data_tablet_id = data_table_schema.get_tablet_id();
|
||||
} else if (OB_FAIL(data_table_schema.get_part_by_idx(part_idx, subpart_idx, data_part))) {
|
||||
@ -439,6 +451,8 @@ int ObTableCreator::generate_create_tablet_arg_(
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(cs_replica_mgr.check_cs_replica_global_visible(ls_id, is_cs_replica_global_visible))) {
|
||||
LOG_WARN("fail to check need process cs replica", KR(ret), K(ls_id));
|
||||
} else if (OB_FAIL(create_tablet_arg.init(
|
||||
tablet_id_array,
|
||||
ls_id,
|
||||
@ -447,7 +461,8 @@ int ObTableCreator::generate_create_tablet_arg_(
|
||||
mode,
|
||||
is_create_bind_hidden_tablets,
|
||||
tenant_data_version,
|
||||
need_create_empty_majors))) {
|
||||
need_create_empty_majors,
|
||||
is_cs_replica_global_visible))) {
|
||||
LOG_WARN("fail to init create tablet arg", KR(ret), K(schemas), K(is_create_bind_hidden_tablets));
|
||||
} else if (OB_FAIL(tablet_creator_.add_create_tablet_arg(create_tablet_arg))) {
|
||||
LOG_WARN("fail to add create tablet arg", KR(ret), K(create_tablet_arg));
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "share/tablet/ob_tablet_info.h" // ObTabletTablePair
|
||||
|
||||
#include "share/tablet/ob_tablet_to_ls_operator.h"
|
||||
#include "storage/column_store/ob_column_store_replica_util.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -95,7 +96,8 @@ private:
|
||||
const int64_t subpart_idx,
|
||||
const bool is_create_bind_hidden_tablets,
|
||||
const uint64_t tenant_data_version,
|
||||
const common::ObIArray<bool> &need_create_empty_majors);
|
||||
const common::ObIArray<bool> &need_create_empty_majors,
|
||||
const ObGlobalCSReplicaMgr &cs_replica_mgr);
|
||||
int get_tablet_list_str_(
|
||||
const share::schema::ObTableSchema &table_schema,
|
||||
ObSqlString &tablet_list);
|
||||
|
@ -51,6 +51,7 @@ void ObTabletCreatorArg::reset()
|
||||
is_create_bind_hidden_tablets_ = false;
|
||||
tenant_data_version_ = 0;
|
||||
need_create_empty_majors_.reset();
|
||||
has_cs_replica_ = false;
|
||||
}
|
||||
|
||||
int ObTabletCreatorArg::assign(const ObTabletCreatorArg &arg)
|
||||
@ -71,6 +72,7 @@ int ObTabletCreatorArg::assign(const ObTabletCreatorArg &arg)
|
||||
compat_mode_ = arg.compat_mode_;
|
||||
is_create_bind_hidden_tablets_ = arg.is_create_bind_hidden_tablets_;
|
||||
tenant_data_version_ = arg.tenant_data_version_;
|
||||
has_cs_replica_ = arg.has_cs_replica_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -83,7 +85,8 @@ int ObTabletCreatorArg::init(
|
||||
const lib::Worker::CompatMode &mode,
|
||||
const bool is_create_bind_hidden_tablets,
|
||||
const uint64_t tenant_data_version,
|
||||
const ObIArray<bool> &need_create_empty_majors)
|
||||
const ObIArray<bool> &need_create_empty_majors,
|
||||
const bool has_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_valid = ls_key.is_valid() && table_schemas.count() > 0
|
||||
@ -110,6 +113,7 @@ int ObTabletCreatorArg::init(
|
||||
compat_mode_ = mode;
|
||||
is_create_bind_hidden_tablets_ = is_create_bind_hidden_tablets;
|
||||
tenant_data_version_ = tenant_data_version;
|
||||
has_cs_replica_ = has_cs_replica;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -118,7 +122,7 @@ DEF_TO_STRING(ObTabletCreatorArg)
|
||||
{
|
||||
int64_t pos = 0;
|
||||
J_KV(K_(compat_mode), K_(tablet_ids), K_(data_tablet_id), K_(ls_key), K_(table_schemas), K_(is_create_bind_hidden_tablets),
|
||||
K_(tenant_data_version), K_(need_create_empty_majors));
|
||||
K_(tenant_data_version), K_(need_create_empty_majors), K_(has_cs_replica));
|
||||
return pos;
|
||||
}
|
||||
|
||||
@ -177,7 +181,8 @@ int ObBatchCreateTabletHelper::add_arg_to_batch_arg(
|
||||
tablet_arg.data_tablet_id_,
|
||||
index_array,
|
||||
tablet_arg.compat_mode_,
|
||||
tablet_arg.is_create_bind_hidden_tablets_))) {
|
||||
tablet_arg.is_create_bind_hidden_tablets_,
|
||||
tablet_arg.has_cs_replica_))) {
|
||||
LOG_WARN("failed to init create tablet info", KR(ret), K(index_array), K(tablet_arg));
|
||||
} else if (OB_FAIL(batch_arg_.tablets_.push_back(info))) {
|
||||
LOG_WARN("failed to push back info", KR(ret), K(info));
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
compat_mode_(lib::Worker::CompatMode::INVALID),
|
||||
is_create_bind_hidden_tablets_(false),
|
||||
tenant_data_version_(0),
|
||||
need_create_empty_majors_() {}
|
||||
need_create_empty_majors_(),
|
||||
has_cs_replica_(false) {}
|
||||
virtual ~ObTabletCreatorArg() {}
|
||||
bool is_valid() const;
|
||||
void reset();
|
||||
@ -51,7 +52,8 @@ public:
|
||||
const lib::Worker::CompatMode &mode,
|
||||
const bool is_create_bind_hidden_tablets,
|
||||
const uint64_t tenant_data_version,
|
||||
const ObIArray<bool> &need_create_empty_majors);
|
||||
const ObIArray<bool> &need_create_empty_majors,
|
||||
const bool has_cs_replica);
|
||||
|
||||
DECLARE_TO_STRING;
|
||||
common::ObArray<common::ObTabletID> tablet_ids_;
|
||||
@ -62,6 +64,7 @@ public:
|
||||
bool is_create_bind_hidden_tablets_;
|
||||
uint64_t tenant_data_version_;
|
||||
common::ObArray<bool> need_create_empty_majors_;
|
||||
bool has_cs_replica_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObTabletCreatorArg);
|
||||
};
|
||||
|
@ -9698,6 +9698,7 @@ void ObCreateTabletInfo::reset()
|
||||
compat_mode_ = lib::Worker::CompatMode::INVALID;
|
||||
is_create_bind_hidden_tablets_ = false;
|
||||
create_commit_versions_.reset();
|
||||
has_cs_replica_ = false;
|
||||
}
|
||||
|
||||
int ObCreateTabletInfo::assign(const ObCreateTabletInfo &info)
|
||||
@ -9716,6 +9717,7 @@ int ObCreateTabletInfo::assign(const ObCreateTabletInfo &info)
|
||||
data_tablet_id_ = info.data_tablet_id_;
|
||||
compat_mode_ = info.compat_mode_;
|
||||
is_create_bind_hidden_tablets_ = info.is_create_bind_hidden_tablets_;
|
||||
has_cs_replica_ = info.has_cs_replica_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -9724,7 +9726,8 @@ int ObCreateTabletInfo::init(const ObIArray<common::ObTabletID> &tablet_ids,
|
||||
common::ObTabletID data_tablet_id,
|
||||
const common::ObIArray<int64_t> &table_schema_index,
|
||||
const lib::Worker::CompatMode &mode,
|
||||
const bool is_create_bind_hidden_tablets)
|
||||
const bool is_create_bind_hidden_tablets,
|
||||
const bool has_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_valid = data_tablet_id.is_valid()
|
||||
@ -9745,6 +9748,7 @@ int ObCreateTabletInfo::init(const ObIArray<common::ObTabletID> &tablet_ids,
|
||||
data_tablet_id_ = data_tablet_id;
|
||||
compat_mode_ = mode;
|
||||
is_create_bind_hidden_tablets_ = is_create_bind_hidden_tablets;
|
||||
has_cs_replica_ = has_cs_replica;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -9752,11 +9756,11 @@ int ObCreateTabletInfo::init(const ObIArray<common::ObTabletID> &tablet_ids,
|
||||
DEF_TO_STRING(ObCreateTabletInfo)
|
||||
{
|
||||
int64_t pos = 0;
|
||||
J_KV(K_(tablet_ids), K_(data_tablet_id), K_(table_schema_index), K_(compat_mode), K_(is_create_bind_hidden_tablets), K_(create_commit_versions));
|
||||
J_KV(K_(tablet_ids), K_(data_tablet_id), K_(table_schema_index), K_(compat_mode), K_(is_create_bind_hidden_tablets), K_(create_commit_versions), K_(has_cs_replica));
|
||||
return pos;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObCreateTabletInfo, tablet_ids_, data_tablet_id_, table_schema_index_, compat_mode_, is_create_bind_hidden_tablets_, create_commit_versions_);
|
||||
OB_SERIALIZE_MEMBER(ObCreateTabletInfo, tablet_ids_, data_tablet_id_, table_schema_index_, compat_mode_, is_create_bind_hidden_tablets_, create_commit_versions_, has_cs_replica_);
|
||||
|
||||
int ObCreateTabletExtraInfo::init(
|
||||
const uint64_t tenant_data_version,
|
||||
|
@ -4074,7 +4074,8 @@ public:
|
||||
const common::ObTabletID data_tablet_id,
|
||||
const common::ObIArray<int64_t> &table_schema_index,
|
||||
const lib::Worker::CompatMode &mode,
|
||||
const bool is_create_bind_hidden_tablets);
|
||||
const bool is_create_bind_hidden_tablets,
|
||||
const bool has_cs_replica);
|
||||
common::ObTabletID get_data_tablet_id() const { return data_tablet_id_; }
|
||||
int64_t get_tablet_count() const { return tablet_ids_.count(); }
|
||||
DECLARE_TO_STRING;
|
||||
@ -4086,6 +4087,7 @@ public:
|
||||
lib::Worker::CompatMode compat_mode_;
|
||||
bool is_create_bind_hidden_tablets_;
|
||||
ObSArray<int64_t> create_commit_versions_;
|
||||
bool has_cs_replica_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObCreateTabletInfo);
|
||||
};
|
||||
|
@ -13,12 +13,14 @@
|
||||
#include "storage/tx_storage/ob_ls_service.h"
|
||||
#include "storage/tablet/ob_mds_schema_helper.h"
|
||||
#include "storage/column_store/ob_column_store_replica_util.h"
|
||||
#include "share/ls/ob_ls_table_operator.h"
|
||||
#define USING_LOG_PREFIX STORAGE
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace storage
|
||||
{
|
||||
ERRSIM_POINT_DEF(EN_LS_NOT_SEE_CS_REPLICA);
|
||||
|
||||
int ObCSReplicaUtil::check_is_cs_replica(
|
||||
const ObTableSchema &table_schema,
|
||||
@ -157,24 +159,109 @@ int ObCSReplicaUtil::check_need_wait_major_convert(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCSReplicaUtil::check_replica_set_need_process_cs_replica(
|
||||
const ObLS &ls,
|
||||
const ObTabletID &tablet_id,
|
||||
int ObCSReplicaUtil::check_need_process_for_cs_replica_for_ddl(
|
||||
const ObTablet &tablet,
|
||||
const ObStorageSchema &schema,
|
||||
bool &need_process_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
need_process_cs_replica = false;
|
||||
if (OB_FAIL(ls.check_has_cs_replica(need_process_cs_replica))) {
|
||||
LOG_WARN("failed to check ls replica set", K(ret), K(ls));
|
||||
} else if (need_process_cs_replica) {
|
||||
need_process_cs_replica = tablet_id.is_user_tablet()
|
||||
&& schema.is_row_store()
|
||||
&& schema.is_user_data_table();
|
||||
const ObTabletMeta &tablet_meta = tablet.get_tablet_meta();
|
||||
const bool cs_replica_visable = tablet_meta.is_cs_replica_global_visable_when_ddl();
|
||||
need_process_cs_replica = cs_replica_visable
|
||||
&& tablet_meta.tablet_id_.is_user_tablet()
|
||||
&& schema.is_row_store()
|
||||
&& schema.is_user_data_table();
|
||||
|
||||
LOG_INFO("[CS-Replica] check replica set need process cs replica", K(ret), K(tablet_meta), K(schema), K(cs_replica_visable), K(need_process_cs_replica));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCSReplicaUtil::check_cs_replica_global_visible(
|
||||
const ObLSInfo &ls_info,
|
||||
bool &is_global_visible)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_global_visible = false;
|
||||
bool has_leader = false;
|
||||
bool has_cs_replica = false;
|
||||
for (int64_t idx = 0; OB_SUCC(ret) && idx < ls_info.get_replicas().count(); ++idx) {
|
||||
const ObLSReplica &replica = ls_info.get_replicas().at(idx);
|
||||
if (ObRole::LEADER == replica.get_role()) {
|
||||
has_leader = true;
|
||||
}
|
||||
if (replica.is_column_replica()) {
|
||||
has_cs_replica = true;
|
||||
}
|
||||
}
|
||||
is_global_visible = has_leader && has_cs_replica;
|
||||
#ifdef ERRSIM
|
||||
if (OB_SUCC(ret)) {
|
||||
if (EN_LS_NOT_SEE_CS_REPLICA) {
|
||||
is_global_visible = false;
|
||||
LOG_INFO("ERRSIM EN_LS_NOT_SEE_CS_REPLICA", K(ret), K(is_global_visible));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCSReplicaUtil::get_cs_replica_ls_set(
|
||||
const ObIArray<share::ObLSID> &ls_id_array,
|
||||
int64_t tenant_id,
|
||||
hash::ObHashSet<share::ObLSID> &contain_cs_replica_ls_id_set)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!contain_cs_replica_ls_id_set.created() || !contain_cs_replica_ls_id_set.empty())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret));
|
||||
} else if (ls_id_array.empty()) {
|
||||
} else if (OB_ISNULL(GCTX.lst_operator_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("lst operator is null", K(ret));
|
||||
} else if (!is_user_tenant(tenant_id)) {
|
||||
} else {
|
||||
const int64_t cluster_id = GCONF.cluster_id;
|
||||
ObSEArray<ObLSInfo, 4> ls_infos;
|
||||
ObSEArray<share::ObLSID, 4> sorted_ls_id_array;
|
||||
ObSEArray<share::ObLSID, 4> unique_ls_id_array;
|
||||
if (OB_FAIL(sorted_ls_id_array.reserve(ls_id_array.count()))) {
|
||||
LOG_WARN("failed to reserve array", K(ret));
|
||||
} else if (OB_FAIL(sorted_ls_id_array.assign(ls_id_array))) {
|
||||
LOG_WARN("failed to assign array", K(ret));
|
||||
} else {
|
||||
// remove duplicated ls_id to do batch_get
|
||||
lib::ob_sort(sorted_ls_id_array.begin(), sorted_ls_id_array.end());
|
||||
for (int64_t idx = 0; OB_SUCC(ret) && idx < sorted_ls_id_array.count(); ++idx) {
|
||||
if (!sorted_ls_id_array.at(idx).is_user_ls()) {
|
||||
} else if (idx >= 1 && sorted_ls_id_array.at(idx) == sorted_ls_id_array.at(idx - 1)) {
|
||||
} else if (OB_FAIL(unique_ls_id_array.push_back(sorted_ls_id_array.at(idx)))) {
|
||||
LOG_WARN("failed to push back", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret) || unique_ls_id_array.empty()) {
|
||||
} else if (OB_FAIL(GCTX.lst_operator_->batch_get(cluster_id, tenant_id, unique_ls_id_array, ObLSTable::DEFAULT_MODE, ls_infos))) {
|
||||
LOG_WARN("failed to get ls infos", K(ret), K(cluster_id), K(tenant_id), K(unique_ls_id_array));
|
||||
} else {
|
||||
// batch get will drop duplicate ls id, so no need to check duplicate
|
||||
for (int64_t idx = 0; OB_SUCC(ret) && idx < ls_infos.count(); ++idx) {
|
||||
const ObLSInfo &ls_info = ls_infos.at(idx);
|
||||
bool is_global_visible = false;
|
||||
if (OB_FAIL(check_cs_replica_global_visible(ls_info, is_global_visible))) {
|
||||
LOG_WARN("failed to check need process cs replica", K(ret), K(ls_info));
|
||||
} else if (!is_global_visible) {
|
||||
} else if (OB_FAIL(contain_cs_replica_ls_id_set.set_refactored(ls_info.get_ls_id()))) {
|
||||
LOG_WARN("failed to set ls id", K(ret), K(ls_info));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*---------------------------------- ObCSReplicaStorageSchemaGuard -------------------------------- */
|
||||
|
||||
ObCSReplicaStorageSchemaGuard::ObCSReplicaStorageSchemaGuard()
|
||||
: is_inited_(false),
|
||||
schema_(nullptr)
|
||||
@ -233,5 +320,56 @@ int ObCSReplicaStorageSchemaGuard::load(ObStorageSchema *&storage_schema)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*---------------------------------- ObGlobalCSReplicaMgr -------------------------------- */
|
||||
|
||||
ObGlobalCSReplicaMgr::ObGlobalCSReplicaMgr()
|
||||
: cs_replica_ls_id_set_(),
|
||||
is_inited_(false)
|
||||
{
|
||||
}
|
||||
|
||||
ObGlobalCSReplicaMgr::~ObGlobalCSReplicaMgr()
|
||||
{
|
||||
if (cs_replica_ls_id_set_.created()) {
|
||||
cs_replica_ls_id_set_.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
int ObGlobalCSReplicaMgr::try_init(const int64_t tenant_id, const ObIArray<share::ObLSID> &ls_id_array)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (IS_INIT) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("init twice", K(ret));
|
||||
} else if (OB_FAIL(cs_replica_ls_id_set_.create(CS_REPLICA_LS_ID_SET_BUCKET_NUM, "CSRplLSIDSet", "CSRplLSIDSet"))) { // use 500 tenant memory since the tenant may not been created
|
||||
LOG_WARN("failed to create cs replica set", K(ret));
|
||||
} else if (OB_FAIL(ObCSReplicaUtil::get_cs_replica_ls_set(ls_id_array, tenant_id, cs_replica_ls_id_set_))) {
|
||||
LOG_WARN("failed to get cs replica ls set", K(ret), K(tenant_id), K(ls_id_array));
|
||||
} else {
|
||||
is_inited_ = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObGlobalCSReplicaMgr::check_cs_replica_global_visible(
|
||||
const share::ObLSID &ls_id,
|
||||
bool &is_global_visible) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
is_global_visible = false;
|
||||
if (IS_NOT_INIT) {
|
||||
// may init failed, it does not matter, take it as like cs replica not visiable
|
||||
} else if (OB_TMP_FAIL(cs_replica_ls_id_set_.exist_refactored(ls_id))) {
|
||||
if (OB_HASH_NOT_EXIST == tmp_ret) {
|
||||
} else if (OB_HASH_EXIST == tmp_ret) {
|
||||
is_global_visible = true;
|
||||
} else {
|
||||
ret = tmp_ret;
|
||||
LOG_WARN("failed to check ls id", K(ret), K(ls_id));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace storage
|
||||
} // namespace oceanbase
|
@ -53,11 +53,17 @@ public:
|
||||
const ObTablet &tablet,
|
||||
bool &need_wait_major_convert);
|
||||
// whole ls replica set need process column store replica for specific tablet
|
||||
static int check_replica_set_need_process_cs_replica(
|
||||
const ObLS &ls,
|
||||
const ObTabletID &tablet_id,
|
||||
static int check_need_process_for_cs_replica_for_ddl(
|
||||
const ObTablet &tablet,
|
||||
const ObStorageSchema &schema,
|
||||
bool &need_process_cs_replica);
|
||||
static int check_cs_replica_global_visible(
|
||||
const ObLSInfo &ls_info,
|
||||
bool &is_global_visible);
|
||||
static int get_cs_replica_ls_set(
|
||||
const ObIArray<share::ObLSID> &ls_id_array,
|
||||
int64_t tenant_id,
|
||||
hash::ObHashSet<share::ObLSID> &contain_cs_replica_ls_id_set);
|
||||
public:
|
||||
static const int64_t DEFAULT_CHECK_LS_REPLICA_LOCATION_TIMEOUT = 10 * 1000 * 1000L; // 10s
|
||||
};
|
||||
@ -78,6 +84,21 @@ private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObCSReplicaStorageSchemaGuard);
|
||||
};
|
||||
|
||||
class ObGlobalCSReplicaMgr final
|
||||
{
|
||||
public:
|
||||
ObGlobalCSReplicaMgr();
|
||||
~ObGlobalCSReplicaMgr();
|
||||
int try_init(const int64_t tenant_id, const ObIArray<share::ObLSID> &ls_id_array);
|
||||
int check_cs_replica_global_visible(const share::ObLSID &ls_id, bool &is_global_visible) const;
|
||||
TO_STRING_KV(K_(is_inited));
|
||||
public:
|
||||
static const int64_t CS_REPLICA_LS_ID_SET_BUCKET_NUM = 31;
|
||||
private:
|
||||
hash::ObHashSet<share::ObLSID> cs_replica_ls_id_set_;
|
||||
bool is_inited_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObGlobalCSReplicaMgr);
|
||||
};
|
||||
|
||||
} // namespace storage
|
||||
} // namespace oceanbase
|
||||
|
@ -403,7 +403,7 @@ DEFINE_GET_SERIALIZE_SIZE(ObDDLClogHeader)
|
||||
|
||||
ObDDLStartLog::ObDDLStartLog()
|
||||
: table_key_(), data_format_version_(0), execution_id_(-1), direct_load_type_(ObDirectLoadType::DIRECT_LOAD_DDL) /*for compatibility*/,
|
||||
lob_meta_tablet_id_(ObDDLClog::COMPATIBLE_LOB_META_TABLET_ID), with_cs_replica_(false)
|
||||
lob_meta_tablet_id_(ObDDLClog::COMPATIBLE_LOB_META_TABLET_ID)
|
||||
{
|
||||
}
|
||||
|
||||
@ -412,8 +412,7 @@ int ObDDLStartLog::init(
|
||||
const uint64_t data_format_version,
|
||||
const int64_t execution_id,
|
||||
const ObDirectLoadType direct_load_type,
|
||||
const ObTabletID &lob_meta_tablet_id,
|
||||
const bool with_cs_replica)
|
||||
const ObTabletID &lob_meta_tablet_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!table_key.is_valid() || execution_id < 0 || data_format_version <= 0 || !is_valid_direct_load(direct_load_type)
|
||||
@ -426,12 +425,11 @@ int ObDDLStartLog::init(
|
||||
execution_id_ = execution_id;
|
||||
direct_load_type_ = direct_load_type;
|
||||
lob_meta_tablet_id_ = lob_meta_tablet_id;
|
||||
with_cs_replica_ = with_cs_replica;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObDDLStartLog, table_key_, data_format_version_, execution_id_, direct_load_type_, lob_meta_tablet_id_, with_cs_replica_);
|
||||
OB_SERIALIZE_MEMBER(ObDDLStartLog, table_key_, data_format_version_, execution_id_, direct_load_type_, lob_meta_tablet_id_);
|
||||
|
||||
ObDDLRedoLog::ObDDLRedoLog()
|
||||
: redo_info_()
|
||||
|
@ -201,23 +201,20 @@ public:
|
||||
const uint64_t data_format_version,
|
||||
const int64_t execution_id,
|
||||
const ObDirectLoadType direct_load_type,
|
||||
const ObTabletID &lob_meta_tablet_id,
|
||||
const bool with_cs_replica);
|
||||
const ObTabletID &lob_meta_tablet_id);
|
||||
bool is_valid() const { return table_key_.is_valid() && data_format_version_ >= 0 && execution_id_ >= 0 && is_valid_direct_load(direct_load_type_); }
|
||||
ObITable::TableKey get_table_key() const { return table_key_; }
|
||||
uint64_t get_data_format_version() const { return data_format_version_; }
|
||||
int64_t get_execution_id() const { return execution_id_; }
|
||||
ObDirectLoadType get_direct_load_type() const { return direct_load_type_; }
|
||||
const ObTabletID &get_lob_meta_tablet_id() const { return lob_meta_tablet_id_; }
|
||||
bool get_with_cs_replica() const { return with_cs_replica_; }
|
||||
TO_STRING_KV(K_(table_key), K_(data_format_version), K_(execution_id), K_(direct_load_type), K_(lob_meta_tablet_id), K_(with_cs_replica));
|
||||
TO_STRING_KV(K_(table_key), K_(data_format_version), K_(execution_id), K_(direct_load_type), K_(lob_meta_tablet_id));
|
||||
private:
|
||||
ObITable::TableKey table_key_; // use table type to distinguish column store, column group id is valid
|
||||
uint64_t data_format_version_; // used for compatibility
|
||||
int64_t execution_id_;
|
||||
ObDirectLoadType direct_load_type_;
|
||||
ObTabletID lob_meta_tablet_id_; // avoid replay get newest mds data
|
||||
bool with_cs_replica_;
|
||||
};
|
||||
|
||||
class ObDDLRedoLog final
|
||||
|
@ -1187,7 +1187,7 @@ int ObDDLRedoLogWriter::write_start_log(
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid arguments", K(ret), K(table_key), K(execution_id), K(data_format_version), K(direct_load_type));
|
||||
} else if (OB_FAIL(log.init(table_key, data_format_version, execution_id, direct_load_type,
|
||||
lob_kv_mgr_handle.is_valid() ? lob_kv_mgr_handle.get_obj()->get_tablet_id() : ObTabletID(), direct_load_mgr_handle.get_obj()->need_process_cs_replica()))) {
|
||||
lob_kv_mgr_handle.is_valid() ? lob_kv_mgr_handle.get_obj()->get_tablet_id() : ObTabletID()))) {
|
||||
LOG_WARN("fail to init DDLStartLog", K(ret), K(table_key), K(execution_id), K(data_format_version));
|
||||
} else if (OB_FAIL(MTL(ObLSService *)->get_ls(ls_id_, ls_handle, ObLSGetMod::DDL_MOD))) {
|
||||
LOG_WARN("get ls failed", K(ret), K(ls_id_));
|
||||
|
@ -274,7 +274,7 @@ int ObDDLStartReplayExecutor::replay_ddl_start(ObTabletHandle &tablet_handle, co
|
||||
table_key = log_->get_table_key();
|
||||
}
|
||||
|
||||
if (!is_lob_meta_tablet && ls_->is_cs_replica() && OB_FAIL(pre_process_for_cs_replica(direct_load_param, table_key, tablet_handle, tablet_id))) {
|
||||
if (!is_lob_meta_tablet && OB_FAIL(tablet_handle.get_obj()->pre_process_cs_replica(direct_load_param.common_param_.direct_load_type_, table_key))) {
|
||||
LOG_WARN("pre process for cs replica failed", K(ret), K(direct_load_param), K(table_key), K(tablet_id));
|
||||
} else if (OB_FAIL(tenant_direct_load_mgr->replay_create_tablet_direct_load(tablet_handle.get_obj(), log_->get_execution_id(), direct_load_param))) {
|
||||
LOG_WARN("create tablet manager failed", K(ret));
|
||||
@ -295,8 +295,7 @@ int ObDDLStartReplayExecutor::replay_ddl_start(ObTabletHandle &tablet_handle, co
|
||||
direct_load_param))) {
|
||||
LOG_WARN("update direct load mgr failed", K(ret));
|
||||
} else if (OB_FAIL(direct_load_mgr_handle.get_full_obj()->start(*tablet_handle.get_obj(),
|
||||
table_key, scn_, log_->get_data_format_version(), log_->get_execution_id(), SCN::min_scn()/*checkpoint_scn*/,
|
||||
direct_load_param.common_param_.replay_normal_in_cs_replica_))) {
|
||||
table_key, scn_, log_->get_data_format_version(), log_->get_execution_id(), SCN::min_scn()/*checkpoint_scn*/))) {
|
||||
LOG_WARN("direct load start failed", K(ret));
|
||||
if (OB_TASK_EXPIRED != ret) {
|
||||
LOG_WARN("start ddl log failed", K(ret), K_(log), K_(scn));
|
||||
@ -311,49 +310,6 @@ int ObDDLStartReplayExecutor::replay_ddl_start(ObTabletHandle &tablet_handle, co
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLStartReplayExecutor::pre_process_for_cs_replica(
|
||||
ObTabletDirectLoadInsertParam &direct_load_param,
|
||||
ObITable::TableKey &table_key,
|
||||
ObTabletHandle &tablet_handle,
|
||||
const ObTabletID &tablet_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (log_->get_with_cs_replica()) {
|
||||
if (log_->get_table_key().is_row_store_major_sstable()) {
|
||||
table_key.table_type_ = ObITable::COLUMN_ORIENTED_SSTABLE; // for passing defence
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid table key for replay ddl start in cs replica", K(ret), K_(log));
|
||||
}
|
||||
} else {
|
||||
// ddl is concurrent with adding C replica
|
||||
const ObTablet *tablet = nullptr;
|
||||
ObStorageSchema *schema_on_tablet = nullptr;
|
||||
ObArenaAllocator tmp_arena("RplyStartTmp");
|
||||
if (OB_UNLIKELY(!tablet_handle.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tablet handle is invalid", K(ret), K(tablet_handle));
|
||||
} else if (OB_ISNULL(tablet = tablet_handle.get_obj())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tablet is null", K(ret), K(tablet_id));
|
||||
} else if (tablet->is_row_store()) {
|
||||
// not be created to column store tablet in cs replica, means this tablet is not user data tablet, ignore
|
||||
} else if (log_->get_table_key().is_column_store_major_sstable()) {
|
||||
// column store tablet originally, ignore
|
||||
} else if (OB_FAIL(tablet->load_storage_schema(tmp_arena, schema_on_tablet))) {
|
||||
LOG_WARN("load storage schema failed", K(ret), KPC(tablet));
|
||||
} else if (schema_on_tablet->is_cs_replica_compat()) {
|
||||
direct_load_param.common_param_.replay_normal_in_cs_replica_ = true;
|
||||
LOG_TRACE("[CS-Replica] process concurrent ddl and ls migration", K(ret), K(tablet_id), KPC(tablet));
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid storage schema status", K(ret), KPC(tablet), KPC(schema_on_tablet));
|
||||
}
|
||||
ObTabletObjLoadHelper::free(tmp_arena, schema_on_tablet);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ObDDLRedoReplayExecutor
|
||||
ObDDLRedoReplayExecutor::ObDDLRedoReplayExecutor()
|
||||
: ObDDLReplayExecutor(), log_(nullptr)
|
||||
|
@ -2379,22 +2379,19 @@ int ObTabletDirectLoadMgr::prepare_storage_schema(ObTabletHandle &tablet_handle)
|
||||
}
|
||||
|
||||
int ObTabletDirectLoadMgr::init_column_store_params(
|
||||
const ObLSHandle &ls_handle,
|
||||
const ObTablet &tablet,
|
||||
const ObStorageSchema &storage_schema,
|
||||
const ObTabletID &new_tablet_id,
|
||||
const ObDirectLoadType new_direct_load_type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObLS *ls = nullptr;
|
||||
bool need_process = false;
|
||||
if (OB_ISNULL(ls = ls_handle.get_ls())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get nullptr ls", K(ret), K(ls_handle));
|
||||
} else if (OB_FAIL(ObCSReplicaUtil::check_replica_set_need_process_cs_replica(*ls, new_tablet_id, storage_schema, need_process))) {
|
||||
LOG_WARN("failed to check ls replica set", K(ret), K(new_tablet_id), KPC(sqc_build_ctx_.storage_schema_));
|
||||
if (OB_FAIL(ObCSReplicaUtil::check_need_process_for_cs_replica_for_ddl(tablet, storage_schema, need_process))) {
|
||||
LOG_WARN("failed to check ls replica set", K(ret), K(tablet), K(storage_schema), K(new_direct_load_type));
|
||||
} else {
|
||||
need_process_cs_replica_ = need_process && is_ddl_direct_load(new_direct_load_type);
|
||||
need_fill_column_group_ = !storage_schema.is_row_store() || need_process_cs_replica_;
|
||||
LOG_INFO("init column store params", K(ret), K(tablet), K(storage_schema), K(new_direct_load_type), K_(need_process_cs_replica), K_(need_fill_column_group));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -2415,11 +2412,14 @@ int ObTabletFullDirectLoadMgr::update(
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLatchWGuard guard(lock_, ObLatchIds::TABLET_DIRECT_LOAD_MGR_LOCK);
|
||||
bool replay_normal_in_cs_replica = false;
|
||||
if (OB_UNLIKELY(!build_param.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid arg", K(ret), K(build_param));
|
||||
} else if (OB_FAIL(ObTabletDirectLoadMgr::update(lob_tablet_mgr, build_param))) {
|
||||
LOG_WARN("init failed", K(ret), K(build_param));
|
||||
} else if (OB_FAIL(pre_process_cs_replica(build_param.common_param_.tablet_id_, replay_normal_in_cs_replica))) {
|
||||
LOG_WARN("failed to pre process cs replica", K(ret), K(build_param));
|
||||
} else {
|
||||
table_key_.reset();
|
||||
table_key_.tablet_id_ = build_param.common_param_.tablet_id_;
|
||||
@ -2429,7 +2429,7 @@ int ObTabletFullDirectLoadMgr::update(
|
||||
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))) {
|
||||
LOG_WARN("fail to get schema is column group store", K(ret));
|
||||
} else if (is_column_group_store && !build_param.common_param_.replay_normal_in_cs_replica_) {
|
||||
} else if (is_column_group_store && !replay_normal_in_cs_replica) {
|
||||
table_key_.table_type_ = ObITable::COLUMN_ORIENTED_SSTABLE;
|
||||
int64_t base_cg_idx = -1;
|
||||
if (OB_FAIL(ObCODDLUtil::get_base_cg_idx(sqc_build_ctx_.storage_schema_, base_cg_idx))) {
|
||||
@ -2497,7 +2497,7 @@ int ObTabletFullDirectLoadMgr::open(const int64_t current_execution_id, share::S
|
||||
} else if (OB_ISNULL(sqc_build_ctx_.storage_schema_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("null storage schema", K(ret), K(sqc_build_ctx_));
|
||||
} else if (OB_FAIL(init_column_store_params(ls_handle, *sqc_build_ctx_.storage_schema_, tablet_id_, direct_load_type_))) {
|
||||
} else if (OB_FAIL(init_column_store_params(*tablet_handle.get_obj(), *sqc_build_ctx_.storage_schema_, direct_load_type_))) {
|
||||
LOG_WARN("failed to refresh cs replica status", K(ret), K(ls_handle), K_(tablet_id));
|
||||
} else {
|
||||
ObDDLKvMgrHandle ddl_kv_mgr_handle;
|
||||
@ -2702,8 +2702,7 @@ int ObTabletFullDirectLoadMgr::start(
|
||||
const share::SCN &start_scn,
|
||||
const uint64_t data_format_version,
|
||||
const int64_t execution_id,
|
||||
const share::SCN &checkpoint_scn,
|
||||
const bool replay_normal_in_cs_replica /*=false*/)
|
||||
const share::SCN &checkpoint_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
share::SCN saved_start_scn;
|
||||
@ -2772,7 +2771,7 @@ int ObTabletFullDirectLoadMgr::start(
|
||||
if (lob_mgr_handle_.is_valid() &&
|
||||
OB_FAIL(lob_mgr_handle_.get_full_obj()->init_ddl_table_store(saved_start_scn, saved_snapshot_version, saved_start_scn))) {
|
||||
LOG_WARN("clean up ddl sstable failed", K(ret));
|
||||
} else if (OB_FAIL(init_ddl_table_store(saved_start_scn, saved_snapshot_version, saved_start_scn, replay_normal_in_cs_replica))) {
|
||||
} else if (OB_FAIL(init_ddl_table_store(saved_start_scn, saved_snapshot_version, saved_start_scn))) {
|
||||
LOG_WARN("clean up ddl sstable failed", K(ret), K(tablet_id_));
|
||||
}
|
||||
}
|
||||
@ -3200,15 +3199,16 @@ int ObTabletFullDirectLoadMgr::cleanup_unlock()
|
||||
int ObTabletFullDirectLoadMgr::init_ddl_table_store(
|
||||
const share::SCN &start_scn,
|
||||
const int64_t snapshot_version,
|
||||
const share::SCN &ddl_checkpoint_scn,
|
||||
const bool replay_normal_in_cs_replica /*=false*/)
|
||||
const share::SCN &ddl_checkpoint_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSHandle ls_handle;
|
||||
ObTabletHandle tablet_handle;
|
||||
ObArenaAllocator tmp_arena("DDLUpdateTblTmp", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
|
||||
ObStorageSchema *storage_schema = nullptr;
|
||||
ObLS *ls = nullptr;
|
||||
bool is_column_group_store = false;
|
||||
bool replay_normal_in_cs_replica = false;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not init", K(ret));
|
||||
@ -3226,8 +3226,12 @@ int ObTabletFullDirectLoadMgr::init_ddl_table_store(
|
||||
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))) {
|
||||
LOG_WARN("fail to check schema is column group store", K(ret));
|
||||
}
|
||||
else {
|
||||
} else if (OB_ISNULL(ls = ls_handle.get_ls())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("ls should not be null", K(ret), K_(ls_id));
|
||||
} else if (ls->is_cs_replica() && OB_FAIL(tablet_handle.get_obj()->pre_process_cs_replica(direct_load_type_, replay_normal_in_cs_replica))) {
|
||||
LOG_WARN("failed to pre process cs replica", K(ret));
|
||||
} else {
|
||||
ObTableHandleV2 table_handle; // empty
|
||||
const int64_t rebuild_seq = ls_handle.get_ls()->get_rebuild_seq();
|
||||
ObTableHandleV2 sstable_handle;
|
||||
@ -3259,7 +3263,6 @@ int ObTabletFullDirectLoadMgr::init_ddl_table_store(
|
||||
param.ddl_info_.ddl_checkpoint_scn_ = ddl_checkpoint_scn;
|
||||
param.ddl_info_.ddl_execution_id_ = execution_id_;
|
||||
param.ddl_info_.data_format_version_ = data_format_version_;
|
||||
param.ddl_info_.ddl_table_type_ = ddl_param.table_key_.table_type_;
|
||||
if (OB_FAIL(ObTabletDDLUtil::create_ddl_sstable(*tablet_handle.get_obj(), ddl_param, empty_meta_array, ObArray<MacroBlockId>(), nullptr/*first_ddl_sstable*/,
|
||||
storage_schema, tmp_arena, sstable_handle))) {
|
||||
LOG_WARN("create empty ddl sstable failed", K(ret));
|
||||
@ -3349,6 +3352,36 @@ int ObTabletFullDirectLoadMgr::update_major_sstable()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletFullDirectLoadMgr::pre_process_cs_replica(
|
||||
const ObTabletID &tablet_id,
|
||||
bool &replay_normal_in_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
replay_normal_in_cs_replica = false;
|
||||
ObLSHandle ls_handle;
|
||||
ObTabletHandle tablet_handle;
|
||||
ObLS *ls = nullptr;
|
||||
ObTablet *tablet = nullptr;
|
||||
if (OB_ISNULL(MTL(ObLSService *))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected err", K(ret));
|
||||
} else if (OB_FAIL(MTL(ObLSService *)->get_ls(ls_id_, ls_handle, ObLSGetMod::DDL_MOD))) {
|
||||
LOG_WARN("get ls failed", K(ret), K(ls_id_));
|
||||
} else if (OB_UNLIKELY(!ls_handle.is_valid()) || OB_ISNULL(ls = ls_handle.get_ls())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("ls handle is invalid or nullptr", K(ret), K(ls_handle), KP(ls));
|
||||
} else if (!ls->is_cs_replica()) {
|
||||
} else if (OB_FAIL(ObDDLUtil::ddl_get_tablet(ls_handle, tablet_id, tablet_handle))) {
|
||||
LOG_WARN("get tablet failed", K(ret));
|
||||
} else if (OB_UNLIKELY(!tablet_handle.is_valid()) || OB_ISNULL(tablet = tablet_handle.get_obj())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("tablet handle is invalid or nullptr", K(ret), K(tablet_handle), KP(tablet));
|
||||
} else if (OB_FAIL(tablet->pre_process_cs_replica(direct_load_type_, replay_normal_in_cs_replica))) {
|
||||
LOG_WARN("failed to pre process cs replica", K(ret), K(ls_id_), K(tablet_id));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ObTabletIncDirectLoadMgr
|
||||
*/
|
||||
|
@ -400,9 +400,8 @@ public:
|
||||
int64_t get_cg_cnt() {return cg_cnt_; }
|
||||
// init column store related parameters when open in leader
|
||||
int init_column_store_params(
|
||||
const ObLSHandle &ls_handle,
|
||||
const ObTablet &tablet,
|
||||
const ObStorageSchema &storage_schema,
|
||||
const ObTabletID &new_tablet_id,
|
||||
const ObDirectLoadType new_direct_load_type);
|
||||
/*
|
||||
* For full data direct load, row store table and column store table take diffrent way.
|
||||
@ -498,8 +497,7 @@ public:
|
||||
const share::SCN &start_scn,
|
||||
const uint64_t data_format_version,
|
||||
const int64_t execution_id,
|
||||
const share::SCN &checkpoint_scn,
|
||||
const bool replay_normal_in_cs_replica = false);
|
||||
const share::SCN &checkpoint_scn);
|
||||
int start_with_checkpoint(
|
||||
ObTablet &tablet,
|
||||
const share::SCN &start_scn,
|
||||
@ -539,8 +537,9 @@ private:
|
||||
bool is_started() { return start_scn_.is_valid_and_not_min(); }
|
||||
int schedule_merge_task(const share::SCN &start_scn, const share::SCN &commit_scn, const bool wait_major_generated, const bool is_replay); // try wait build major sstable
|
||||
int cleanup_unlock();
|
||||
int init_ddl_table_store(const share::SCN &start_scn, const int64_t snapshot_version, const share::SCN &ddl_checkpoint_scn, const bool replay_normal_in_cs_replica = false);
|
||||
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);
|
||||
|
||||
private:
|
||||
share::SCN start_scn_;
|
||||
|
@ -238,13 +238,13 @@ struct ObDirectInsertCommonParam final
|
||||
{
|
||||
public:
|
||||
ObDirectInsertCommonParam()
|
||||
: ls_id_(), tablet_id_(), direct_load_type_(DIRECT_LOAD_INVALID), data_format_version_(0), read_snapshot_(0), replay_normal_in_cs_replica_(false)
|
||||
: ls_id_(), tablet_id_(), direct_load_type_(DIRECT_LOAD_INVALID), data_format_version_(0), read_snapshot_(0)
|
||||
{}
|
||||
~ObDirectInsertCommonParam() = default;
|
||||
bool is_valid() const { return ls_id_.is_valid() && tablet_id_.is_valid()
|
||||
&& data_format_version_ >= 0 && read_snapshot_ >= 0 && DIRECT_LOAD_INVALID <= direct_load_type_ && direct_load_type_ <= DIRECT_LOAD_MAX;
|
||||
}
|
||||
TO_STRING_KV(K_(ls_id), K_(tablet_id), K_(direct_load_type), K_(data_format_version), K_(read_snapshot), K_(replay_normal_in_cs_replica));
|
||||
TO_STRING_KV(K_(ls_id), K_(tablet_id), K_(direct_load_type), K_(data_format_version), K_(read_snapshot));
|
||||
public:
|
||||
share::ObLSID ls_id_;
|
||||
common::ObTabletID tablet_id_;
|
||||
@ -253,7 +253,6 @@ public:
|
||||
// read_snapshot_ is used to scan the source data.
|
||||
// For full direct load task, it is also the commit version of the target macro block.
|
||||
int64_t read_snapshot_;
|
||||
bool replay_normal_in_cs_replica_; // when ddl and add cs replica are concurrent, leader may write normal clog
|
||||
};
|
||||
|
||||
// only used in runtime execution
|
||||
|
@ -89,7 +89,6 @@ using namespace rootserver;
|
||||
|
||||
namespace storage
|
||||
{
|
||||
ERRSIM_POINT_DEF(EN_LS_NOT_SEE_CS_REPLICA);
|
||||
|
||||
using namespace checkpoint;
|
||||
using namespace mds;
|
||||
@ -504,11 +503,22 @@ int ObLS::check_has_cs_replica(bool &has_cs_replica) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
has_cs_replica = false;
|
||||
ObRole role = INVALID_ROLE;
|
||||
ObMemberList member_list;
|
||||
GlobalLearnerList learner_list;
|
||||
int64_t proposal_id = 0;
|
||||
int64_t paxos_replica_number = 0;
|
||||
if (OB_FAIL(get_paxos_member_list_and_learner_list(member_list, paxos_replica_number, learner_list))) {
|
||||
LOG_WARN("fail to get member list and learner list", K(ret), K(ls_meta_.ls_id_));
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ls is not inited", K(ret));
|
||||
} else if (OB_FAIL(log_handler_.get_role(role, proposal_id))) {
|
||||
LOG_WARN("fail to get role", K(ret), KPC(this));
|
||||
} else if (LEADER != role) {
|
||||
ret = OB_NOT_MASTER;
|
||||
LOG_WARN("local ls is not leader", K(ret), K_(ls_meta));
|
||||
} else if (OB_FAIL(get_paxos_member_list_and_learner_list(member_list, paxos_replica_number, learner_list))) {
|
||||
LOG_WARN("fail to get member list and learner list", K(ret), K_(ls_meta));
|
||||
} else {
|
||||
for (int64_t i = 0; i < learner_list.get_member_number(); i++) {
|
||||
const ObMember &learner = learner_list.get_learner(i);
|
||||
@ -518,16 +528,6 @@ int ObLS::check_has_cs_replica(bool &has_cs_replica) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ERRSIM
|
||||
if (OB_SUCC(ret)) {
|
||||
if (EN_LS_NOT_SEE_CS_REPLICA) {
|
||||
has_cs_replica = false;
|
||||
LOG_INFO("ERRSIM EN_LS_NOT_SEE_CS_REPLICA", K(ret), K(has_cs_replica));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2380,6 +2380,7 @@ int ObLSTabletService::create_tablet(
|
||||
const lib::Worker::CompatMode &compat_mode,
|
||||
const bool need_create_empty_major_sstable,
|
||||
const bool micro_index_clustered,
|
||||
const bool has_cs_replica,
|
||||
ObTabletHandle &tablet_handle)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -2407,7 +2408,8 @@ int ObLSTabletService::create_tablet(
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("new tablet is null", K(ret), KP(tablet), KP(allocator), K(tablet_handle));
|
||||
} else if (OB_FAIL(tablet->init_for_first_time_creation(*allocator, ls_id, tablet_id, data_tablet_id,
|
||||
create_scn, snapshot_version, create_tablet_schema, need_create_empty_major_sstable, micro_index_clustered, need_generate_cs_replica_cg_array, freezer))) {
|
||||
create_scn, snapshot_version, create_tablet_schema, need_create_empty_major_sstable, micro_index_clustered,
|
||||
need_generate_cs_replica_cg_array, has_cs_replica, freezer))) {
|
||||
LOG_WARN("failed to init tablet", K(ret), K(ls_id), K(tablet_id), K(data_tablet_id),
|
||||
K(create_scn), K(snapshot_version), K(create_tablet_schema));
|
||||
} else if (OB_FAIL(tablet->get_updating_tablet_pointer_param(param))) {
|
||||
@ -2464,7 +2466,8 @@ int ObLSTabletService::create_inner_tablet(
|
||||
LOG_ERROR("new tablet is null", K(ret), KPC(tmp_tablet), K(tmp_tablet_hdl));
|
||||
} else if (FALSE_IT(time_guard.click("CreateTablet"))) {
|
||||
} else if (OB_FAIL(tmp_tablet->init_for_first_time_creation(allocator, ls_id, tablet_id, data_tablet_id,
|
||||
create_scn, snapshot_version, create_tablet_schema, true/*need_create_empty_major_sstable*/, false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, freezer))) {
|
||||
create_scn, snapshot_version, create_tablet_schema, true/*need_create_empty_major_sstable*/,
|
||||
false/*micro_index_clustered*/, false/*need_generate_cs_replica_cg_array*/, false/*has_cs_replica*/, freezer))) {
|
||||
LOG_WARN("failed to init tablet", K(ret), K(ls_id), K(tablet_id), K(data_tablet_id),
|
||||
K(create_scn), K(snapshot_version), K(create_tablet_schema));
|
||||
} else if (FALSE_IT(time_guard.click("InitTablet"))) {
|
||||
|
@ -167,6 +167,7 @@ public:
|
||||
const lib::Worker::CompatMode &compat_mode,
|
||||
const bool need_create_empty_major_sstable,
|
||||
const bool micro_index_clustered,
|
||||
const bool has_cs_replica,
|
||||
ObTabletHandle &tablet_handle);
|
||||
int create_transfer_in_tablet(
|
||||
const share::ObLSID &ls_id,
|
||||
|
@ -50,7 +50,8 @@ int64_t ObBatchCreateTabletPrettyArg::to_string(char *buf, const int64_t buf_len
|
||||
J_KV("data_tablet_id", info.data_tablet_id_,
|
||||
"tablet_ids", info.tablet_ids_,
|
||||
"compat_mode", info.compat_mode_,
|
||||
"is_create_bind_hidden_tablets", info.is_create_bind_hidden_tablets_);
|
||||
"is_create_bind_hidden_tablets", info.is_create_bind_hidden_tablets_,
|
||||
"has_cs_replica", info.has_cs_replica_);
|
||||
}
|
||||
J_NEWLINE();
|
||||
J_OBJ_END();
|
||||
|
@ -338,6 +338,7 @@ int ObTablet::init_for_first_time_creation(
|
||||
const bool need_create_empty_major_sstable,
|
||||
const bool micro_index_clustered,
|
||||
const bool need_generate_cs_replica_cg_array,
|
||||
const bool has_cs_replica,
|
||||
ObFreezer *freezer)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -371,7 +372,7 @@ int ObTablet::init_for_first_time_creation(
|
||||
LOG_WARN("failed to init shared params", K(ret), K(ls_id), K(tablet_id), K(compat_mode), KP(freezer));
|
||||
} else if (OB_FAIL(tablet_meta_.init(ls_id, tablet_id, data_tablet_id,
|
||||
create_scn, snapshot_version, compat_mode, table_store_flag, create_tablet_schema.get_schema_version()/*create_schema_version*/,
|
||||
micro_index_clustered))) {
|
||||
micro_index_clustered, has_cs_replica))) {
|
||||
LOG_WARN("failed to init tablet meta", K(ret), K(ls_id), K(tablet_id), K(data_tablet_id),
|
||||
K(create_scn), K(snapshot_version), K(compat_mode), K(table_store_flag));
|
||||
} else if (OB_FAIL(pull_memtables(allocator))) {
|
||||
@ -592,7 +593,8 @@ int ObTablet::init_for_shared_merge(
|
||||
old_tablet.tablet_meta_.compat_mode_,
|
||||
old_tablet.tablet_meta_.table_store_flag_,
|
||||
old_tablet.tablet_meta_.create_schema_version_,
|
||||
old_tablet.tablet_meta_.micro_index_clustered_))) {
|
||||
old_tablet.tablet_meta_.micro_index_clustered_,
|
||||
false /*has_cs_replica*/))) {
|
||||
LOG_WARN("failed to init tablet meta", K(ret), K(old_tablet), K(param));
|
||||
} else if (OB_FAIL(ObStorageSchemaUtil::alloc_storage_schema(allocator, storage_schema_addr_.ptr_))) {
|
||||
LOG_WARN("failed to alloc mem for tmp storage schema", K(ret));
|
||||
@ -5816,27 +5818,53 @@ int ObTablet::check_row_store_with_co_major(bool &is_row_store_with_co_major) co
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::pre_process_cs_replica(ObTabletDirectLoadInsertParam &direct_load_param)
|
||||
int ObTablet::pre_process_cs_replica(
|
||||
const ObDirectLoadType direct_load_type,
|
||||
bool &replay_normal_in_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObITable::TableKey table_key;
|
||||
if (OB_FAIL(inner_pre_process_cs_replica(direct_load_type, table_key, replay_normal_in_cs_replica))) {
|
||||
LOG_WARN("failed to pre process cs replica", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::pre_process_cs_replica(
|
||||
const ObDirectLoadType direct_load_type,
|
||||
ObITable::TableKey &table_key)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool replay_normal_in_cs_replica = false;
|
||||
if (ObITable::is_column_store_sstable(table_key.table_type_)) {
|
||||
} else if (OB_FAIL(inner_pre_process_cs_replica(direct_load_type, table_key, replay_normal_in_cs_replica))) {
|
||||
LOG_WARN("failed to pre process cs replica", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTablet::inner_pre_process_cs_replica(
|
||||
const ObDirectLoadType direct_load_type,
|
||||
ObITable::TableKey &table_key,
|
||||
bool &replay_normal_in_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObLSHandle ls_handle;
|
||||
ObLS *ls = nullptr;
|
||||
bool is_cs_replica_compat = false;
|
||||
if (OB_FAIL(MTL(ObLSService *)->get_ls(tablet_meta_.ls_id_, ls_handle, ObLSGetMod::DDL_MOD))) {
|
||||
LOG_WARN("failed to get ls", K(ret), "ls_id", tablet_meta_.ls_id_);
|
||||
} else if (OB_UNLIKELY(!ls_handle.is_valid()) || OB_ISNULL(ls = ls_handle.get_ls())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("ls handle is invalid or nullptr", K(ret), K(ls_handle), KP(ls));
|
||||
} else if (!ls->is_cs_replica()) {
|
||||
} else if (is_row_store()) {
|
||||
replay_normal_in_cs_replica = false;
|
||||
if (is_row_store() || !is_ddl_direct_load(direct_load_type)) {
|
||||
// do not need to process cs replica
|
||||
} else if (OB_FAIL(check_cs_replica_compat_schema(is_cs_replica_compat))) {
|
||||
LOG_WARN("failed to check cs replica compat", K(ret), KPC(this));
|
||||
} else if (is_cs_replica_compat && tablet_meta_.ddl_table_type_ == ObITable::DDL_DUMP_SSTABLE) {
|
||||
direct_load_param.common_param_.replay_normal_in_cs_replica_ = true;
|
||||
LOG_INFO("[CS-Replica] Set replay normal in cs replica", K(direct_load_param));
|
||||
} else if (is_cs_replica_compat) {
|
||||
if (tablet_meta_.is_cs_replica_global_visable_when_ddl()) {
|
||||
table_key.table_type_ = ObITable::COLUMN_ORIENTED_SSTABLE; // for passing defence
|
||||
} else {
|
||||
replay_normal_in_cs_replica = true;
|
||||
}
|
||||
LOG_INFO("[CS-Replica] Set replay normal in cs replica", K(direct_load_type), K(table_key), K(replay_normal_in_cs_replica));
|
||||
}
|
||||
LOG_TRACE("[CS-Replica] process cs replica when start direct load task", KPC(ls), K(is_cs_replica_compat), K(direct_load_param), K_(tablet_meta));
|
||||
LOG_TRACE("[CS-Replica] process cs replica when start direct load task", K(ret), K(is_cs_replica_compat),
|
||||
K(direct_load_type), K(table_key), K(replay_normal_in_cs_replica), K_(tablet_meta));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -5891,9 +5919,7 @@ int ObTablet::start_direct_load_task_if_need()
|
||||
direct_load_param.common_param_.direct_load_type_ = ObDirectLoadType::DIRECT_LOAD_DDL;
|
||||
direct_load_param.common_param_.read_snapshot_ = tablet_meta_.ddl_snapshot_version_;
|
||||
|
||||
if (OB_FAIL(pre_process_cs_replica(direct_load_param))) {
|
||||
LOG_WARN("failed to process cs replica", K(ret), KPC(this));
|
||||
} else if (OB_FAIL(tenant_direct_load_mgr->replay_create_tablet_direct_load(
|
||||
if (OB_FAIL(tenant_direct_load_mgr->replay_create_tablet_direct_load(
|
||||
this, tablet_meta_.ddl_execution_id_, direct_load_param))) {
|
||||
LOG_WARN("create tablet manager failed", K(ret));
|
||||
} else if (OB_FAIL(tenant_direct_load_mgr->get_tablet_mgr(
|
||||
|
@ -184,6 +184,7 @@ public:
|
||||
const bool need_create_empty_major_sstable,
|
||||
const bool micro_index_clustered,
|
||||
const bool need_generate_cs_replica_cg_array,
|
||||
const bool has_cs_replica,
|
||||
ObFreezer *freezer);
|
||||
// dump/merge build new multi version tablet
|
||||
int init_for_merge(
|
||||
@ -469,10 +470,21 @@ public:
|
||||
int get_migration_sstable_size(int64_t &data_size);
|
||||
|
||||
// column store replica
|
||||
public:
|
||||
int check_cs_replica_compat_schema(bool &is_cs_replica_compat) const;
|
||||
int check_row_store_with_co_major(bool &is_row_store_with_co_major) const;
|
||||
int pre_process_cs_replica(ObTabletDirectLoadInsertParam &direct_load_param);
|
||||
|
||||
int pre_process_cs_replica(
|
||||
const ObDirectLoadType direct_load_type,
|
||||
bool &replay_normal_in_cs_replica);
|
||||
int pre_process_cs_replica(
|
||||
const ObDirectLoadType direct_load_type,
|
||||
ObITable::TableKey &table_key);
|
||||
private:
|
||||
int inner_pre_process_cs_replica(
|
||||
const ObDirectLoadType direct_load_type,
|
||||
ObITable::TableKey &table_key,
|
||||
bool &replay_normal_in_cs_replica);
|
||||
public:
|
||||
// other
|
||||
const ObMetaDiskAddr &get_tablet_addr() const { return tablet_addr_; }
|
||||
const ObTabletMeta &get_tablet_meta() const { return tablet_meta_; }
|
||||
|
@ -676,6 +676,7 @@ int ObTabletCreateMdsHelper::build_pure_data_tablet(
|
||||
const ObSArray<obrpc::ObCreateTabletExtraInfo> &create_tablet_extra_infos = arg.tablet_extra_infos_;
|
||||
const lib::Worker::CompatMode &compat_mode = info.compat_mode_;
|
||||
const int64_t snapshot_version = arg.major_frozen_scn_.get_val_for_tx();
|
||||
const bool has_cs_replica = info.has_cs_replica_;
|
||||
ObTabletHandle tablet_handle;
|
||||
bool exist = false;
|
||||
int64_t index = -1;
|
||||
@ -718,7 +719,7 @@ int ObTabletCreateMdsHelper::build_pure_data_tablet(
|
||||
LOG_WARN("check and get create tablet schema_info failed", K(ret));
|
||||
} else if (CLICK_FAIL(ls->get_tablet_svr()->create_tablet(ls_id, data_tablet_id, data_tablet_id,
|
||||
scn, snapshot_version, *create_tablet_schema, compat_mode,
|
||||
need_create_empty_major_sstable, micro_index_clustered, tablet_handle))) {
|
||||
need_create_empty_major_sstable, micro_index_clustered, has_cs_replica, tablet_handle))) {
|
||||
LOG_WARN("failed to do create tablet", K(ret), K(ls_id), K(data_tablet_id), "arg", PRETTY_ARG(arg));
|
||||
}
|
||||
|
||||
@ -747,6 +748,7 @@ int ObTabletCreateMdsHelper::build_mixed_tablets(
|
||||
const lib::Worker::CompatMode &compat_mode = info.compat_mode_;
|
||||
const ObSArray<obrpc::ObCreateTabletExtraInfo> &create_tablet_extra_infos = arg.tablet_extra_infos_;
|
||||
const int64_t snapshot_version = arg.major_frozen_scn_.get_val_for_tx();
|
||||
const bool has_cs_replica = info.has_cs_replica_;
|
||||
ObTabletHandle data_tablet_handle;
|
||||
ObTabletHandle tablet_handle;
|
||||
ObTabletID lob_meta_tablet_id;
|
||||
@ -801,7 +803,7 @@ int ObTabletCreateMdsHelper::build_mixed_tablets(
|
||||
LOG_WARN("failed to push back tablet id", K(ret), K(ls_id), K(tablet_id));
|
||||
} else if (CLICK_FAIL(ls->get_tablet_svr()->create_tablet(ls_id, tablet_id, data_tablet_id,
|
||||
scn, snapshot_version, *create_tablet_schema, compat_mode,
|
||||
need_create_empty_major_sstable, micro_index_clustered, tablet_handle))) {
|
||||
need_create_empty_major_sstable, micro_index_clustered, has_cs_replica, tablet_handle))) {
|
||||
LOG_WARN("failed to do create tablet", K(ret), K(ls_id), K(tablet_id), K(data_tablet_id), "arg", PRETTY_ARG(arg));
|
||||
}
|
||||
|
||||
@ -848,6 +850,7 @@ int ObTabletCreateMdsHelper::build_pure_aux_tablets(
|
||||
const lib::Worker::CompatMode &compat_mode = info.compat_mode_;
|
||||
const ObSArray<obrpc::ObCreateTabletExtraInfo> &create_tablet_extra_infos = arg.tablet_extra_infos_;
|
||||
const int64_t snapshot_version = arg.major_frozen_scn_.get_val_for_tx();
|
||||
const bool has_cs_replica = info.has_cs_replica_;
|
||||
ObTabletHandle tablet_handle;
|
||||
bool exist = false;
|
||||
ObLSHandle ls_handle;
|
||||
@ -892,7 +895,7 @@ int ObTabletCreateMdsHelper::build_pure_aux_tablets(
|
||||
LOG_WARN("check and get create tablet schema_info failed", K(ret));
|
||||
} else if (CLICK_FAIL(ls->get_tablet_svr()->create_tablet(ls_id, tablet_id, data_tablet_id,
|
||||
scn, snapshot_version, *create_tablet_schema, compat_mode,
|
||||
need_create_empty_major_sstable, micro_index_clustered, tablet_handle))) {
|
||||
need_create_empty_major_sstable, micro_index_clustered, has_cs_replica, tablet_handle))) {
|
||||
LOG_WARN("failed to do create tablet", K(ret), K(ls_id), K(tablet_id), K(data_tablet_id), "arg", PRETTY_ARG(arg));
|
||||
}
|
||||
|
||||
@ -924,6 +927,7 @@ int ObTabletCreateMdsHelper::build_bind_hidden_tablets(
|
||||
const lib::Worker::CompatMode &compat_mode = info.compat_mode_;
|
||||
const ObSArray<obrpc::ObCreateTabletExtraInfo> &create_tablet_extra_infos = arg.tablet_extra_infos_;
|
||||
const int64_t snapshot_version = arg.major_frozen_scn_.get_val_for_tx();
|
||||
const bool has_cs_replica = info.has_cs_replica_;
|
||||
ObTabletHandle tablet_handle;
|
||||
int64_t aux_info_idx = -1;
|
||||
ObTabletID lob_meta_tablet_id;
|
||||
@ -991,7 +995,7 @@ int ObTabletCreateMdsHelper::build_bind_hidden_tablets(
|
||||
LOG_WARN("failed to push back tablet id", K(ret), K(ls_id), K(tablet_id));
|
||||
} else if (CLICK_FAIL(ls->get_tablet_svr()->create_tablet(ls_id, tablet_id, tablet_id,
|
||||
scn, snapshot_version, *create_tablet_schema, compat_mode,
|
||||
need_create_empty_major_sstable, micro_index_clustered, tablet_handle))) {
|
||||
need_create_empty_major_sstable, micro_index_clustered, has_cs_replica, tablet_handle))) {
|
||||
LOG_WARN("failed to do create tablet", K(ret), K(ls_id), K(tablet_id), K(orig_tablet_id), "arg", PRETTY_ARG(arg));
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,8 @@ int ObTabletMeta::init(
|
||||
const lib::Worker::CompatMode compat_mode,
|
||||
const ObTabletTableStoreFlag &table_store_flag,
|
||||
const int64_t create_schema_version,
|
||||
const bool micro_index_clustered)
|
||||
const bool micro_index_clustered,
|
||||
const bool has_cs_replica)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -126,7 +127,7 @@ int ObTabletMeta::init(
|
||||
ddl_snapshot_version_ = 0;
|
||||
max_sync_storage_schema_version_ = create_schema_version;
|
||||
ddl_data_format_version_ = 0;
|
||||
ddl_table_type_ = ObITable::DDL_MEM_SSTABLE;
|
||||
ddl_table_type_ = has_cs_replica ? ObITable::DDL_MERGE_CO_SSTABLE : ObITable::DDL_DUMP_SSTABLE;
|
||||
mds_checkpoint_scn_ = INIT_CLOG_CHECKPOINT_SCN;
|
||||
report_status_.merge_snapshot_version_ = snapshot_version;
|
||||
report_status_.cur_report_version_ = snapshot_version;
|
||||
@ -1022,6 +1023,11 @@ int ObTabletMeta::update_meta_last_persisted_committed_tablet_status(
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObTabletMeta::is_cs_replica_global_visable_when_ddl() const
|
||||
{
|
||||
return ObITable::is_column_store_sstable(ddl_table_type_);
|
||||
}
|
||||
|
||||
ObMigrationTabletParam::ObMigrationTabletParam()
|
||||
: magic_number_(MAGIC_NUM),
|
||||
version_(PARAM_VERSION_V3), // TODO(@gaishun.gs): set version to v3
|
||||
|
@ -69,7 +69,8 @@ public:
|
||||
const lib::Worker::CompatMode compat_mode,
|
||||
const ObTabletTableStoreFlag &table_store_flag,
|
||||
const int64_t create_schema_version,
|
||||
const bool micro_index_clustered);
|
||||
const bool micro_index_clustered,
|
||||
const bool has_cs_replica);
|
||||
int init(
|
||||
const ObTabletMeta &old_tablet_meta,
|
||||
const int64_t snapshot_version,
|
||||
@ -105,6 +106,8 @@ public:
|
||||
// mds_checkpoint_scn and ddl_checkpoint_scn.
|
||||
// Note, if a new type of checkpoint scn is added, donot forget to modify the returned scn.
|
||||
share::SCN get_max_replayed_scn() const;
|
||||
// for column store replica
|
||||
bool is_cs_replica_global_visable_when_ddl() const;
|
||||
public:
|
||||
static int deserialize_id(
|
||||
const char *buf,
|
||||
|
@ -113,7 +113,8 @@ int __attribute__((weak)) gen_create_tablet_arg(const int64_t tenant_id,
|
||||
tablet_id,
|
||||
index_tablet_schema_idxs,
|
||||
lib::Worker::CompatMode::MYSQL,
|
||||
false))) {
|
||||
false,
|
||||
false /*has_cs_replica*/))) {
|
||||
STORAGE_LOG(WARN, "failed to init tablet info", KR(ret), K(index_tablet_ids),
|
||||
K(tablet_id), K(index_tablet_schema_idxs));
|
||||
} else if (OB_FAIL(arg.init_create_tablet(ls_id, share::SCN::min_scn(), false/*need_check_tablet_cnt*/))) {
|
||||
|
@ -444,7 +444,7 @@ int TestCompactionPolicy::mock_tablet(
|
||||
} else if (FALSE_IT(need_generate_cs_replica_cg_array = ls_handle.get_ls()->is_cs_replica() && create_tablet_schema.is_row_store() && create_tablet_schema.is_user_data_table())) {
|
||||
} else if (OB_FAIL(tablet->init_for_first_time_creation(allocator, ls_id, tablet_id, tablet_id,
|
||||
SCN::min_scn(), snapshot_version, create_tablet_schema, need_empty_major_table,
|
||||
false/*micro_index_clustered*/, need_generate_cs_replica_cg_array, ls_handle.get_ls()->get_freezer()))) {
|
||||
false/*micro_index_clustered*/, need_generate_cs_replica_cg_array, false/*has_cs_replica*/, ls_handle.get_ls()->get_freezer()))) {
|
||||
LOG_WARN("failed to init tablet", K(ret), K(ls_id), K(tablet_id), K(snapshot_version),
|
||||
K(table_schema), K(compat_mode));
|
||||
} else {
|
||||
|
@ -575,7 +575,7 @@ int TestDmlCommon::build_pure_data_tablet_arg(
|
||||
STORAGE_LOG(WARN, "failed to push tablet id into array", K(ret), K(data_tablet_id));
|
||||
} else if (OB_FAIL(tablet_schema_index_array.push_back(0))) {
|
||||
STORAGE_LOG(WARN, "failed to push index into array", K(ret));
|
||||
} else if (OB_FAIL(tablet_info.init(tablet_id_array, data_tablet_id, tablet_schema_index_array, lib::Worker::CompatMode::MYSQL, false))) {
|
||||
} else if (OB_FAIL(tablet_info.init(tablet_id_array, data_tablet_id, tablet_schema_index_array, lib::Worker::CompatMode::MYSQL, false, false /*has_cs_replica*/))) {
|
||||
STORAGE_LOG(WARN, "failed to init tablet info", K(ret), K(tablet_id_array),
|
||||
K(data_tablet_id), K(tablet_schema_index_array));
|
||||
} else if (OB_FAIL(arg.init_create_tablet(ls_id, share::SCN::min_scn(), false/*need_check_tablet_cnt*/))) {
|
||||
@ -627,7 +627,7 @@ int TestDmlCommon::build_mixed_tablets_arg(
|
||||
STORAGE_LOG(WARN, "failed to push index into array", K(ret));
|
||||
} else if (OB_FAIL(tablet_schema_index_array.push_back(1))) {
|
||||
STORAGE_LOG(WARN, "failed to push index into array", K(ret));
|
||||
} else if (OB_FAIL(tablet_info.init(tablet_id_array, data_tablet_id, tablet_schema_index_array, lib::Worker::CompatMode::MYSQL, false))) {
|
||||
} else if (OB_FAIL(tablet_info.init(tablet_id_array, data_tablet_id, tablet_schema_index_array, lib::Worker::CompatMode::MYSQL, false, false /*has_cs_replica*/))) {
|
||||
STORAGE_LOG(WARN, "failed to init tablet info", K(ret), K(tablet_id_array),
|
||||
K(data_tablet_id), K(tablet_schema_index_array));
|
||||
} else if (OB_FAIL(arg.init_create_tablet(ls_id, share::SCN::min_scn(), false/*need_check_tablet_cnt*/))) {
|
||||
|
@ -139,7 +139,7 @@ inline int TestTabletHelper::create_tablet(
|
||||
*tablet_handle.get_allocator(),
|
||||
ls_id, tablet_id, tablet_id, share::SCN::base_scn(),
|
||||
snapshot_version, create_tablet_schema, need_create_empty_major_sstable,
|
||||
false/*micro_index_clustered*/, need_generate_cs_replica_cg_array, freezer))){
|
||||
false/*micro_index_clustered*/, need_generate_cs_replica_cg_array, false/*has_cs_replica*/, freezer))){
|
||||
STORAGE_LOG(WARN, "failed to init tablet", K(ret), K(ls_id), K(tablet_id));
|
||||
} else if (ObTabletStatus::Status::MAX != tablet_status) {
|
||||
ObTabletCreateDeleteMdsUserData data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user