record lob meta tablet id in ddl clog

This commit is contained in:
simonjoylet
2024-02-27 10:19:48 +00:00
committed by ob-robot
parent 6924042fbd
commit d5c6c78fe2
5 changed files with 78 additions and 39 deletions

View File

@ -391,7 +391,8 @@ DEFINE_GET_SERIALIZE_SIZE(ObDDLClogHeader)
} }
ObDDLStartLog::ObDDLStartLog() ObDDLStartLog::ObDDLStartLog()
: table_key_(), data_format_version_(0), execution_id_(-1), direct_load_type_(ObDirectLoadType::DIRECT_LOAD_DDL) /*for compatibility*/ : 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)
{ {
} }
@ -399,22 +400,25 @@ int ObDDLStartLog::init(
const ObITable::TableKey &table_key, const ObITable::TableKey &table_key,
const uint64_t data_format_version, const uint64_t data_format_version,
const int64_t execution_id, const int64_t execution_id,
const ObDirectLoadType direct_load_type) const ObDirectLoadType direct_load_type,
const ObTabletID &lob_meta_tablet_id)
{ {
int ret = OB_SUCCESS; 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))) { if (OB_UNLIKELY(!table_key.is_valid() || execution_id < 0 || data_format_version <= 0 || !is_valid_direct_load(direct_load_type)
|| ObDDLClog::COMPATIBLE_LOB_META_TABLET_ID == lob_meta_tablet_id.id())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(table_key), K(execution_id), K(data_format_version), K(direct_load_type)); LOG_WARN("invalid argument", K(ret), K(table_key), K(execution_id), K(data_format_version), K(direct_load_type), K(lob_meta_tablet_id));
} else { } else {
table_key_ = table_key; table_key_ = table_key;
data_format_version_ = data_format_version; data_format_version_ = data_format_version;
execution_id_ = execution_id; execution_id_ = execution_id;
direct_load_type_ = direct_load_type; direct_load_type_ = direct_load_type;
lob_meta_tablet_id_ = lob_meta_tablet_id;
} }
return ret; return ret;
} }
OB_SERIALIZE_MEMBER(ObDDLStartLog, table_key_, data_format_version_, execution_id_, direct_load_type_); OB_SERIALIZE_MEMBER(ObDDLStartLog, table_key_, data_format_version_, execution_id_, direct_load_type_, lob_meta_tablet_id_);
ObDDLRedoLog::ObDDLRedoLog() ObDDLRedoLog::ObDDLRedoLog()
: redo_info_() : redo_info_()
@ -436,25 +440,28 @@ int ObDDLRedoLog::init(const blocksstable::ObDDLMacroBlockRedoInfo &redo_info)
OB_SERIALIZE_MEMBER(ObDDLRedoLog, redo_info_); OB_SERIALIZE_MEMBER(ObDDLRedoLog, redo_info_);
ObDDLCommitLog::ObDDLCommitLog() ObDDLCommitLog::ObDDLCommitLog()
: table_key_(), start_scn_(SCN::min_scn()) : table_key_(), start_scn_(SCN::min_scn()), lob_meta_tablet_id_(ObDDLClog::COMPATIBLE_LOB_META_TABLET_ID)
{ {
} }
int ObDDLCommitLog::init(const ObITable::TableKey &table_key, int ObDDLCommitLog::init(const ObITable::TableKey &table_key,
const SCN &start_scn) const SCN &start_scn,
const ObTabletID &lob_meta_tablet_id)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (!table_key.is_valid() || !start_scn.is_valid_and_not_min()) { if (OB_UNLIKELY(!table_key.is_valid() || !start_scn.is_valid_and_not_min()
|| ObDDLClog::COMPATIBLE_LOB_META_TABLET_ID == lob_meta_tablet_id.id())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(table_key), K(start_scn)); LOG_WARN("invalid argument", K(ret), K(table_key), K(start_scn), K(lob_meta_tablet_id));
} else { } else {
table_key_ = table_key; table_key_ = table_key;
start_scn_ = start_scn; start_scn_ = start_scn;
lob_meta_tablet_id_ = lob_meta_tablet_id;
} }
return ret; return ret;
} }
OB_SERIALIZE_MEMBER(ObDDLCommitLog, table_key_, start_scn_); OB_SERIALIZE_MEMBER(ObDDLCommitLog, table_key_, start_scn_, lob_meta_tablet_id_);
ObTabletSchemaVersionChangeLog::ObTabletSchemaVersionChangeLog() ObTabletSchemaVersionChangeLog::ObTabletSchemaVersionChangeLog()

View File

@ -180,24 +180,36 @@ private:
ObDDLClogType ddl_clog_type_; ObDDLClogType ddl_clog_type_;
}; };
class ObDDLClog
{
public:
static const uint64_t COMPATIBLE_LOB_META_TABLET_ID = 1;
};
class ObDDLStartLog final class ObDDLStartLog final
{ {
OB_UNIS_VERSION_V(1); OB_UNIS_VERSION_V(1);
public: public:
ObDDLStartLog(); ObDDLStartLog();
~ObDDLStartLog() = default; ~ObDDLStartLog() = default;
int init(const ObITable::TableKey &table_key, const uint64_t data_format_version, const int64_t execution_id, const ObDirectLoadType direct_load_type); int init(const ObITable::TableKey &table_key,
const uint64_t data_format_version,
const int64_t execution_id,
const ObDirectLoadType direct_load_type,
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_); } 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_; } ObITable::TableKey get_table_key() const { return table_key_; }
uint64_t get_data_format_version() const { return data_format_version_; } uint64_t get_data_format_version() const { return data_format_version_; }
int64_t get_execution_id() const { return execution_id_; } int64_t get_execution_id() const { return execution_id_; }
ObDirectLoadType get_direct_load_type() const { return direct_load_type_; } ObDirectLoadType get_direct_load_type() const { return direct_load_type_; }
TO_STRING_KV(K_(table_key), K_(data_format_version), K_(execution_id), K_(direct_load_type)); const ObTabletID &get_lob_meta_tablet_id() const { return lob_meta_tablet_id_; }
TO_STRING_KV(K_(table_key), K_(data_format_version), K_(execution_id), K_(direct_load_type), K_(lob_meta_tablet_id));
private: private:
ObITable::TableKey table_key_; // use table type to distinguish column store, column group id is valid ObITable::TableKey table_key_; // use table type to distinguish column store, column group id is valid
uint64_t data_format_version_; // used for compatibility uint64_t data_format_version_; // used for compatibility
int64_t execution_id_; int64_t execution_id_;
ObDirectLoadType direct_load_type_; ObDirectLoadType direct_load_type_;
ObTabletID lob_meta_tablet_id_; // avoid replay get newest mds data
}; };
class ObDDLRedoLog final class ObDDLRedoLog final
@ -221,14 +233,17 @@ public:
ObDDLCommitLog(); ObDDLCommitLog();
~ObDDLCommitLog() = default; ~ObDDLCommitLog() = default;
int init(const ObITable::TableKey &table_key, int init(const ObITable::TableKey &table_key,
const share::SCN &start_scn); const share::SCN &start_scn,
const ObTabletID &lob_meta_tablet_id);
bool is_valid() const { return table_key_.is_valid() && start_scn_.is_valid(); } bool is_valid() const { return table_key_.is_valid() && start_scn_.is_valid(); }
ObITable::TableKey get_table_key() const { return table_key_; } ObITable::TableKey get_table_key() const { return table_key_; }
share::SCN get_start_scn() const { return start_scn_; } share::SCN get_start_scn() const { return start_scn_; }
TO_STRING_KV(K_(table_key), K_(start_scn)); const ObTabletID &get_lob_meta_tablet_id() const { return lob_meta_tablet_id_; }
TO_STRING_KV(K_(table_key), K_(start_scn), K_(lob_meta_tablet_id));
private: private:
ObITable::TableKey table_key_; ObITable::TableKey table_key_;
share::SCN start_scn_; share::SCN start_scn_;
ObTabletID lob_meta_tablet_id_; // avoid replay get newest mds data
}; };
class ObTabletSchemaVersionChangeLog final class ObTabletSchemaVersionChangeLog final

View File

@ -1135,7 +1135,8 @@ int ObDDLRedoLogWriter::write_start_log(
} else if (OB_UNLIKELY(!table_key.is_valid() || execution_id < 0 || data_format_version <= 0 || !is_valid_direct_load(direct_load_type))) { } else if (OB_UNLIKELY(!table_key.is_valid() || execution_id < 0 || data_format_version <= 0 || !is_valid_direct_load(direct_load_type))) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), K(table_key), K(execution_id), K(data_format_version), K(direct_load_type)); 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))) { } 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()))) {
LOG_WARN("fail to init DDLStartLog", K(ret), K(table_key), K(execution_id), K(data_format_version)); 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))) { } 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_)); LOG_WARN("get ls failed", K(ret), K(ls_id_));
@ -1282,14 +1283,17 @@ int ObDDLRedoLogWriter::write_commit_log(
ObLS *ls = nullptr; ObLS *ls = nullptr;
ObDDLCommitLog log; ObDDLCommitLog log;
ObDDLCommitLogHandle handle; ObDDLCommitLogHandle handle;
ObTabletBindingMdsUserData ddl_data;
if (OB_UNLIKELY(!is_inited_)) { if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
LOG_WARN("ddl redo log writer has not been inited", K(ret)); LOG_WARN("ddl redo log writer has not been inited", K(ret));
} else if (OB_UNLIKELY(!table_key.is_valid() || !start_scn.is_valid_and_not_min())) { } else if (OB_UNLIKELY(!table_key.is_valid() || !start_scn.is_valid_and_not_min())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), K(table_key), K(start_scn)); LOG_WARN("invalid arguments", K(ret), K(table_key), K(start_scn));
} else if (OB_FAIL(log.init(table_key, start_scn))) { } else if (OB_FAIL(tablet_handle.get_obj()->ObITabletMdsInterface::get_ddl_data(share::SCN::max_scn(), ddl_data))) {
LOG_WARN("fail to init DDLCommitLog", K(ret), K(table_key), K(start_scn)); LOG_WARN("failed to get ddl data from tablet", K(ret), K(tablet_handle));
} else if (OB_FAIL(log.init(table_key, start_scn, ddl_data.lob_meta_tablet_id_))) {
LOG_WARN("fail to init DDLCommitLog", K(ret), K(table_key), K(start_scn), K(ddl_data.lob_meta_tablet_id_));
} else if (OB_FAIL(MTL(ObLSService *)->get_ls(ls_id_, ls_handle, ObLSGetMod::DDL_MOD))) { } 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_)); LOG_WARN("get ls failed", K(ret), K(ls_id_));
} else if (OB_ISNULL(ls = ls_handle.get_ls())) { } else if (OB_ISNULL(ls = ls_handle.get_ls())) {

View File

@ -42,7 +42,6 @@ int ObDDLReplayExecutor::check_need_replay_ddl_log_(
ObTablet *tablet = nullptr; ObTablet *tablet = nullptr;
ObDDLKvMgrHandle ddl_kv_mgr_handle; ObDDLKvMgrHandle ddl_kv_mgr_handle;
ObMigrationStatus migration_status; ObMigrationStatus migration_status;
ObTabletBindingMdsUserData ddl_data;
if (OB_UNLIKELY(nullptr == ls || !tablet_handle.is_valid() || !ddl_start_scn.is_valid_and_not_min() || !scn.is_valid_and_not_min())) { if (OB_UNLIKELY(nullptr == ls || !tablet_handle.is_valid() || !ddl_start_scn.is_valid_and_not_min() || !scn.is_valid_and_not_min())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("not init", K(ret), KP(ls), K(tablet_handle), K(ddl_start_scn), K(scn)); LOG_WARN("not init", K(ret), KP(ls), K(tablet_handle), K(ddl_start_scn), K(scn));
@ -79,21 +78,31 @@ int ObDDLReplayExecutor::check_need_replay_ddl_log_(
LOG_INFO("no need to replay ddl log, because the ddl start log ts is less than the value in ddl kv manager", LOG_INFO("no need to replay ddl log, because the ddl start log ts is less than the value in ddl kv manager",
K(tablet_handle), K(ddl_start_scn), "ddl_start_scn_in_tablet", tablet->get_tablet_meta().ddl_start_scn_); K(tablet_handle), K(ddl_start_scn), "ddl_start_scn_in_tablet", tablet->get_tablet_meta().ddl_start_scn_);
} }
} else if (OB_FAIL(tablet_handle.get_obj()->ObITabletMdsInterface::get_ddl_data(share::SCN::max_scn(), ddl_data))) {
LOG_WARN("failed to get ddl data from tablet", K(ret), K(tablet_handle));
} else if (ddl_data.lob_meta_tablet_id_.is_valid()) {
ObTabletHandle lob_tablet_handle;
const ObTabletID lob_tablet_id = ddl_data.lob_meta_tablet_id_;
if (OB_FAIL(ls->replay_get_tablet_no_check(lob_tablet_id, scn, lob_tablet_handle))) {
LOG_WARN("get tablet handle failed", K(ret), K(lob_tablet_id), K(scn));
} else if (lob_tablet_handle.get_obj()->is_empty_shell()) {
need_replay = false;
LOG_INFO("lob tablet is empty shell, skip replay", K(ret), "tablet_id", tablet->get_tablet_id(), K(lob_tablet_id));
}
} }
return ret; return ret;
} }
int ObDDLReplayExecutor::get_lob_meta_tablet_id(
const ObTabletHandle &tablet_handle,
const common::ObTabletID &possible_lob_meta_tablet_id,
common::ObTabletID &lob_meta_tablet_id)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!tablet_handle.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(tablet_handle));
} else if (ObDDLClog::COMPATIBLE_LOB_META_TABLET_ID == possible_lob_meta_tablet_id.id()) { // compatible code
ObTabletBindingMdsUserData ddl_data;
if (OB_FAIL(tablet_handle.get_obj()->ObITabletMdsInterface::get_ddl_data(share::SCN::max_scn(), ddl_data))) {
LOG_WARN("failed to get ddl data from tablet", K(ret), K(tablet_handle));
} else {
lob_meta_tablet_id = ddl_data.lob_meta_tablet_id_;
}
} else {
lob_meta_tablet_id = possible_lob_meta_tablet_id;
}
return ret;
}
// ObDDLStartReplayExecutor // ObDDLStartReplayExecutor
ObDDLStartReplayExecutor::ObDDLStartReplayExecutor() ObDDLStartReplayExecutor::ObDDLStartReplayExecutor()
@ -129,18 +138,17 @@ int ObDDLStartReplayExecutor::init(
int ObDDLStartReplayExecutor::do_replay_(ObTabletHandle &tablet_handle) int ObDDLStartReplayExecutor::do_replay_(ObTabletHandle &tablet_handle)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObTabletBindingMdsUserData ddl_data; ObTabletID lob_meta_tablet_id;
if (OB_UNLIKELY(!is_inited_)) { if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
LOG_WARN("ObDDLRedoLogReplayer has not been inited", K(ret)); LOG_WARN("ObDDLRedoLogReplayer has not been inited", K(ret));
} else if (OB_UNLIKELY(!log_->is_valid() || !tablet_handle.is_valid())) { } else if (OB_UNLIKELY(!log_->is_valid() || !tablet_handle.is_valid())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), K_(log), K(tablet_handle)); LOG_WARN("invalid arguments", K(ret), K_(log), K(tablet_handle));
} else if (OB_FAIL(tablet_handle.get_obj()->ObITabletMdsInterface::get_ddl_data(share::SCN::max_scn(), ddl_data))) { } else if (OB_FAIL(ObDDLReplayExecutor::get_lob_meta_tablet_id(tablet_handle, log_->get_lob_meta_tablet_id(), lob_meta_tablet_id))) {
LOG_WARN("failed to get ddl data from tablet", K(ret), K(tablet_handle)); LOG_WARN("get lob meta tablet id failed", K(ret));
} else if (ddl_data.lob_meta_tablet_id_.is_valid()) { } else if (lob_meta_tablet_id.is_valid()) {
ObTabletHandle lob_meta_tablet_handle; ObTabletHandle lob_meta_tablet_handle;
const ObTabletID &lob_meta_tablet_id = ddl_data.lob_meta_tablet_id_;
if (OB_FAIL(ls_->replay_get_tablet_no_check(lob_meta_tablet_id, scn_, lob_meta_tablet_handle))) { if (OB_FAIL(ls_->replay_get_tablet_no_check(lob_meta_tablet_id, scn_, lob_meta_tablet_handle))) {
LOG_WARN("get tablet handle failed", K(ret), K(lob_meta_tablet_id), K(scn_)); LOG_WARN("get tablet handle failed", K(ret), K(lob_meta_tablet_id), K(scn_));
} else if (OB_FAIL(replay_ddl_start(lob_meta_tablet_handle, true/*is_lob_meta_tablet*/))) { } else if (OB_FAIL(replay_ddl_start(lob_meta_tablet_handle, true/*is_lob_meta_tablet*/))) {
@ -404,18 +412,17 @@ int ObDDLCommitReplayExecutor::init(
int ObDDLCommitReplayExecutor::do_replay_(ObTabletHandle &tablet_handle) int ObDDLCommitReplayExecutor::do_replay_(ObTabletHandle &tablet_handle)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObTabletBindingMdsUserData ddl_data; ObTabletID lob_meta_tablet_id;
if (OB_UNLIKELY(!is_inited_)) { if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
LOG_WARN("ObDDLRedoLogReplayer has not been inited", K(ret)); LOG_WARN("ObDDLRedoLogReplayer has not been inited", K(ret));
} else if (OB_UNLIKELY(!log_->is_valid() || !tablet_handle.is_valid())) { } else if (OB_UNLIKELY(!log_->is_valid() || !tablet_handle.is_valid())) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), K_(log), K(tablet_handle)); LOG_WARN("invalid arguments", K(ret), K_(log), K(tablet_handle));
} else if (OB_FAIL(tablet_handle.get_obj()->ObITabletMdsInterface::get_ddl_data(share::SCN::max_scn(), ddl_data))) { } else if (OB_FAIL(ObDDLReplayExecutor::get_lob_meta_tablet_id(tablet_handle, log_->get_lob_meta_tablet_id(), lob_meta_tablet_id))) {
LOG_WARN("failed to get ddl data from tablet", K(ret), K(tablet_handle)); LOG_WARN("get lob meta tablet id failed", K(ret));
} else if (ddl_data.lob_meta_tablet_id_.is_valid()) { } else if (lob_meta_tablet_id.is_valid()) {
ObTabletHandle lob_meta_tablet_handle; ObTabletHandle lob_meta_tablet_handle;
const ObTabletID &lob_meta_tablet_id = ddl_data.lob_meta_tablet_id_;
if (OB_FAIL(ls_->replay_get_tablet_no_check(lob_meta_tablet_id, scn_, lob_meta_tablet_handle))) { if (OB_FAIL(ls_->replay_get_tablet_no_check(lob_meta_tablet_id, scn_, lob_meta_tablet_handle))) {
LOG_WARN("get tablet handle failed", K(ret), K(lob_meta_tablet_id), K(scn_)); LOG_WARN("get tablet handle failed", K(ret), K(lob_meta_tablet_id), K(scn_));
} else if (OB_FAIL(replay_ddl_commit(lob_meta_tablet_handle))) { } else if (OB_FAIL(replay_ddl_commit(lob_meta_tablet_handle))) {

View File

@ -45,6 +45,12 @@ protected:
const share::SCN &scn, const share::SCN &scn,
bool &need_replay); bool &need_replay);
static int get_lob_meta_tablet_id(
const ObTabletHandle &tablet_handle,
const common::ObTabletID &possible_lob_meta_tablet_id,
common::ObTabletID &lob_meta_tablet_id);
virtual bool is_replay_update_mds_table_() const override virtual bool is_replay_update_mds_table_() const override
{ {
return false; return false;