提交 cd8fb2e1 编写于 作者: K KyrielightWei 提交者: ob-robot

rewrite dup_tablet_set for a special op to avoid executing sp_op failed

上级 e35dc626
......@@ -25,9 +25,10 @@ using namespace storage;
namespace transaction
{
const uint64_t DupTableDiagStd::DUP_DIAG_INFO_LOG_BUF_LEN[3] = {
const uint64_t DupTableDiagStd::DUP_DIAG_INFO_LOG_BUF_LEN[DupTableDiagStd::TypeIndex::MAX_INDEX] = {
1 << 12, // 4K
1 << 16, // 64k
1 << 20, // 1M
1 << 17, // 128K
1 << 12, // 4k
};
const char *DupTableDiagStd::DUP_DIAG_INDENT_SPACE = " "; // 4
......@@ -35,7 +36,8 @@ const char *DupTableDiagStd::DUP_DIAG_COMMON_PREFIX = "DUP_TABLE_DIAG: ";
const int64_t DupTableDiagStd::DUP_DIAG_PRINT_INTERVAL[DupTableDiagStd::TypeIndex::MAX_INDEX] = {
ObDupTableLSLeaseMgr::DEFAULT_LEASE_INTERVAL,
30 * 1000 * 1000, // 10s , tablet_print_interval
3 * 60 * 1000 * 1000 // 3min , ts_sync_print_interval
30 * 1000 * 1000, // 10s , tablet_print_interval
5 * 60 * 1000 * 1000 // 3min , ts_sync_print_interval
};
......@@ -217,7 +219,23 @@ OB_SERIALIZE_MEMBER(DupTableLeaseLogHeader, addr_, lease_log_code_);
/*******************************************************
* Dup_Table Tablets
*******************************************************/
// nothing
bool DupTabletSetCommonHeader::operator==(const DupTabletSetCommonHeader &dup_common_header) const
{
bool compare_res = false;
if (unique_id_ == dup_common_header.unique_id_
&& tablet_set_type_ == dup_common_header.tablet_set_type_
&& sp_op_type_ == dup_common_header.sp_op_type_) {
compare_res = true;
}
return compare_res;
}
bool DupTabletSetCommonHeader::operator!=(const DupTabletSetCommonHeader &dup_common_header) const
{
return !((*this) == dup_common_header);
}
/*******************************************************
* Dup_Table Checkpoint
......@@ -963,6 +981,7 @@ int ObDupTableLogOperator::deserialize_log_entry_()
int ObDupTableLogOperator::retry_submit_log_block_()
{
int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS;
int64_t block_buf_pos = 0;
if (OB_ISNULL(block_buf_)) {
......@@ -977,6 +996,13 @@ int ObDupTableLogOperator::retry_submit_log_block_()
logservice::ObLogBaseHeader base_header(logservice::ObLogBaseType::DUP_TABLE_LOG_BASE_TYPE,
logservice::ObReplayBarrierType::NO_NEED_BARRIER,
ls_id_.hash());
share::SCN gts_base_scn = share::SCN::min_scn();
if (OB_TMP_FAIL(OB_TS_MGR.get_gts(MTL_ID(), nullptr, gts_base_scn))) {
DUP_TABLE_LOG(WARN, "get gts cache for base scn failed", K(ret), K(tmp_ret), K(gts_base_scn));
gts_base_scn = share::SCN::min_scn();
}
bool unused = false;
if (!big_segment_buf_.is_active()) {
ret = OB_ERR_UNEXPECTED;
......@@ -993,8 +1019,8 @@ int ObDupTableLogOperator::retry_submit_log_block_()
ret = OB_LOG_TOO_LARGE;
DUP_TABLE_LOG(WARN, "Too large dup table log. We can not submit it", K(ret),
K(big_segment_buf_.is_completed()), KPC(this));
} else if (OB_FAIL(log_handler_->append(block_buf_, block_buf_pos, share::SCN::min_scn(), false,
this, logging_lsn_, logging_scn_))) {
} else if (OB_FAIL(log_handler_->append(block_buf_, block_buf_pos, gts_base_scn, false, this,
logging_lsn_, logging_scn_))) {
DUP_TABLE_LOG(WARN, "append block failed", K(ret), K(ls_id_));
}
}
......
......@@ -53,7 +53,8 @@ public:
enum TypeIndex
{
LEASE_INDEX = 0,
TABLET_INDEX,
TBALET_MEMBER_INDEX,
TABLET_SET_INDEX,
TS_SYNC_INDEX,
MAX_INDEX,
};
......@@ -673,12 +674,11 @@ private:
// static const uint64_t SPECIAL_OP_BIT_COUNT = 8;
// static const uint64_t UNIQUE_ID_BIT = static_cast<uint64_t>(0xFFFFFFFFULL);
// static const uint64_t TABLET_SET_BIT = static_cast<uint64_t>(0xFULL) << UNIQUE_ID_BIT_COUNT;
// static const uint64_t SPECIAL_OP_BIT = static_cast<uint64_t>(0xFFULL) << (UNIQUE_ID_BIT_COUNT + TABLET_SET_BIT_COUNT);
// static const uint64_t SPECIAL_OP_BIT = static_cast<uint64_t>(0xFFULL) << (UNIQUE_ID_BIT_COUNT +
// TABLET_SET_BIT_COUNT);
public:
TO_STRING_KV(K(unique_id_),
K(tablet_set_type_),
K(sp_op_type_));
TO_STRING_KV(K(unique_id_), K(tablet_set_type_), K(sp_op_type_));
DupTabletSetCommonHeader(const uint64_t id) : unique_id_(id)
{
......@@ -689,9 +689,7 @@ public:
DupTabletSetCommonHeader() { reset(); }
~DupTabletSetCommonHeader() { reset(); }
bool is_valid() const {
return unique_id_is_valid() && tablet_set_type_is_valid();
}
bool is_valid() const { return unique_id_is_valid() && tablet_set_type_is_valid(); }
void reset()
{
set_invalid_unique_id();
......@@ -739,14 +737,8 @@ public:
{
return DUP_SPECIAL_OP_CLEAN_DATA_CONFIRMING_SET == sp_op_type_;
}
void set_op_of_block_confirming()
{
set_special_op_(DUP_SPECIAL_OP_BLOCK_CONFIRMING);
}
bool need_block_confirming() const
{
return DUP_SPECIAL_OP_BLOCK_CONFIRMING == sp_op_type_;
}
void set_op_of_block_confirming() { set_special_op_(DUP_SPECIAL_OP_BLOCK_CONFIRMING); }
bool need_block_confirming() const { return DUP_SPECIAL_OP_BLOCK_CONFIRMING == sp_op_type_; }
// bool contain_special_op(uint64_t special_op) const { return get_special_op_() == special_op; }
bool no_specail_op() const { return INVALID_SPECIAL_OP == sp_op_type_; }
void copy_tablet_set_type(const DupTabletSetCommonHeader &src_common_header)
......@@ -756,6 +748,10 @@ public:
change_tablet_set_type_(src_common_header.get_tablet_set_type());
}
public:
bool operator==(const DupTabletSetCommonHeader &dup_common_header) const;
bool operator!=(const DupTabletSetCommonHeader &dup_common_header) const;
private:
void set_unique_id_(const uint64_t id)
{
......@@ -767,19 +763,10 @@ private:
}
unique_id_ = id;
}
void change_tablet_set_type_(const int64_t set_type)
{
tablet_set_type_ = set_type;
}
int64_t get_tablet_set_type_() const
{
return tablet_set_type_;
}
void change_tablet_set_type_(const int64_t set_type) { tablet_set_type_ = set_type; }
int64_t get_tablet_set_type_() const { return tablet_set_type_; }
void set_special_op_(const int64_t special_op_type)
{
sp_op_type_ = special_op_type;
}
void set_special_op_(const int64_t special_op_type) { sp_op_type_ = special_op_type; }
int64_t get_special_op_() const
{
// return (common_code_ & SPECIAL_OP_BIT) >> (UNIQUE_ID_BIT_COUNT + TABLET_SET_BIT_COUNT);
......
......@@ -410,41 +410,6 @@ int ObDupTableLSLeaseMgr::handle_lease_req_cache_(int64_t loop_start_time,
return ret;
}
// int ObDupTableLSLeaseMgr::leader_handle(bool &need_log)
// {
// int ret = OB_SUCCESS;
//
// SpinWLockGuard guard(lease_lock_);
//
// common::ObAddr tmp_addr;
// int64_t loop_start_time = ObTimeUtility::current_time();
// DupTableTsInfo local_ts_info;
// need_log = false;
//
// if (need_retry_lease_operation_(loop_start_time, last_lease_req_cache_handle_time_)) {
// if (OB_FAIL(dup_ls_handle_ptr_->get_local_ts_info(local_ts_info))) {
// need_log = false;
// DUP_TABLE_LOG(WARN, "get local ts info failed", K(ret), K(ls_id_), K(local_ts_info));
// } else {
// LeaseReqCacheHandler req_handler(this, loop_start_time, local_ts_info.max_replayed_scn_);
// if (OB_FAIL(hash_for_each_remove(tmp_addr, leader_lease_map_, req_handler))) {
// DUP_TABLE_LOG(WARN, "handle lease requests failed", K(ret));
// }
//
// last_lease_req_cache_handle_time_ = loop_start_time;
// if (req_handler.get_lease_changed()) {
// need_log = true;
// } else {
// need_log = false;
// }
// }
// } else {
// need_log = false;
// }
// DUP_TABLE_LOG(DEBUG, "leader handler", K(loop_start_time), K(need_log));
// return ret;
// }
//
int ObDupTableLSLeaseMgr::follower_handle()
{
int ret = OB_SUCCESS;
......@@ -452,7 +417,7 @@ int ObDupTableLSLeaseMgr::follower_handle()
if (ATOMIC_LOAD(&is_stopped_)) {
ret = OB_NOT_INIT;
DUP_TABLE_LOG(WARN, "dup table lease mgr is not inited", K(ret));
} else if (dup_ls_handle_ptr_->get_local_ts_info(local_ts_info)) {
} else if (OB_FAIL(dup_ls_handle_ptr_->get_local_ts_info(local_ts_info))) {
DUP_TABLE_LOG(WARN, "get local ts info failed", K(ret));
} else {
SpinWLockGuard guard(lease_lock_);
......
......@@ -339,6 +339,11 @@ public:
{
return dup_set_attr_.change_status_.need_reserve(scn);
}
share::SCN get_tablet_change_scn() { return dup_set_attr_.change_status_.tablet_change_scn_; }
const DupTabletSetChangeStatus &get_RO_change_status() const
{
return dup_set_attr_.change_status_;
}
bool is_logging() const { return dup_set_attr_.change_status_.check_logging(); }
void set_logging() { dup_set_attr_.change_status_.set_logging(); }
......@@ -492,7 +497,7 @@ class ObLSDupTabletsMgr
{
public:
ObLSDupTabletsMgr()
: changing_new_set_(nullptr), removing_old_set_(nullptr), tablet_diag_info_log_buf_(nullptr)
: changing_new_set_(nullptr), removing_old_set_(nullptr), tablet_set_diag_info_log_buf_(nullptr),tablet_id_diag_info_log_buf_(nullptr)
{
reset();
}
......@@ -678,10 +683,10 @@ private:
int get_target_tablet_set_(const DupTabletSetCommonHeader &target_common_header,
DupTabletChangeMap *&target_set,
const bool construct_target_set = false,
const bool need_changing_new_set = false);
const bool force_search_target_set = false);
int check_and_recycle_empty_readable_set(DupTabletChangeMap *need_free_set, bool &need_remove);
int return_tablet_set(DupTabletChangeMap *need_free_set);
int check_and_recycle_empty_readable_set_(DupTabletChangeMap *need_free_set, bool &need_remove);
int return_tablet_set_(DupTabletChangeMap *need_free_set);
int clean_readable_tablets_(const share::SCN &min_reserve_tablet_scn);
int clean_durable_confirming_tablets_(const share::SCN &min_reserve_tablet_scn);
......@@ -703,6 +708,10 @@ private:
int merge_into_readable_tablets_(DupTabletChangeMap *change_map_ptr, const bool for_replay);
int validate_replay_dup_tablet_set(const DupTabletSetCommonHeader &target_common_header,
const DupTabletSetChangeStatus &target_change_status,
DupTabletChangeMap *replay_target_set);
private:
//
static int64_t GC_DUP_TABLETS_TIME_INTERVAL; // 5 min
......@@ -745,7 +754,8 @@ private:
int64_t last_no_free_set_time_;
int64_t extra_free_set_alloc_count_;
char *tablet_diag_info_log_buf_;
char *tablet_set_diag_info_log_buf_;
char *tablet_id_diag_info_log_buf_;
};
class ObLSDupTablets
......
......@@ -726,10 +726,10 @@ int ObDupTableLSHandler::ls_loop_handle()
last_diag_info_print_us_[DupTableDiagStd::TypeIndex::LEASE_INDEX] = fast_cur_time;
}
if (fast_cur_time - last_diag_info_print_us_[DupTableDiagStd::TypeIndex::TABLET_INDEX]
>= DupTableDiagStd::DUP_DIAG_PRINT_INTERVAL[DupTableDiagStd::TypeIndex::TABLET_INDEX]) {
if (fast_cur_time - last_diag_info_print_us_[DupTableDiagStd::TypeIndex::TABLET_SET_INDEX]
>= DupTableDiagStd::DUP_DIAG_PRINT_INTERVAL[DupTableDiagStd::TypeIndex::TABLET_SET_INDEX]) {
tablets_mgr_ptr_->print_tablet_diag_info_log(is_leader);
last_diag_info_print_us_[DupTableDiagStd::TypeIndex::TABLET_INDEX] = fast_cur_time;
last_diag_info_print_us_[DupTableDiagStd::TypeIndex::TABLET_SET_INDEX] = fast_cur_time;
}
if (fast_cur_time - last_diag_info_print_us_[DupTableDiagStd::TypeIndex::TS_SYNC_INDEX]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册