check dup tablet after acquire max_commit_ts

This commit is contained in:
KyrielightWei
2023-08-24 12:40:35 +00:00
committed by ob-robot
parent eb33a615ea
commit 6a1c07923b
13 changed files with 260 additions and 119 deletions

View File

@ -697,7 +697,7 @@ int ObSqlTransControl::stmt_setup_snapshot_(ObSQLSessionInfo *session,
stmt_expire_ts, stmt_expire_ts,
snapshot))) { snapshot))) {
} else { } else {
local_single_ls_plan = has_same_lsid(das_ctx, snapshot.core_.version_, first_ls_id); local_single_ls_plan = has_same_lsid(das_ctx, snapshot, first_ls_id);
} }
} }
if (OB_SUCC(ret) && !local_single_ls_plan) { if (OB_SUCC(ret) && !local_single_ls_plan) {
@ -798,12 +798,13 @@ int ObSqlTransControl::get_first_lsid(const ObDASCtx &das_ctx, share::ObLSID &fi
} }
bool ObSqlTransControl::has_same_lsid(const ObDASCtx &das_ctx, bool ObSqlTransControl::has_same_lsid(const ObDASCtx &das_ctx,
const share::SCN &snapshot_version, const transaction::ObTxReadSnapshot &snapshot,
share::ObLSID &first_lsid) share::ObLSID &first_lsid)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
bool bret = true; bool bret = true;
ObLSHandle ls_handle; ObLSHandle ls_handle;
const share::SCN snapshot_version = snapshot.core_.version_;
const DASTableLocList &table_locs = das_ctx.get_table_loc_list(); const DASTableLocList &table_locs = das_ctx.get_table_loc_list();
FOREACH_X(table_node, table_locs, bret) { FOREACH_X(table_node, table_locs, bret) {
ObDASTableLoc *table_loc = *table_node; ObDASTableLoc *table_loc = *table_node;
@ -847,6 +848,17 @@ bool ObSqlTransControl::has_same_lsid(const ObDASCtx &das_ctx,
} }
} }
} }
if (bret && common::ObRole::FOLLOWER == snapshot.snapshot_ls_role_) {
ObLS *ls = NULL;
if (OB_ISNULL(ls = ls_handle.get_ls())) {
bret = false;
LOG_WARN("invalid ls", K(bret), K(first_lsid), K(snapshot));
} else if (!(ls->get_dup_table_ls_handler()->is_dup_tablet(tablet_id))) {
bret = false;
LOG_WARN("There is a normal tablet, retry to acquire snapshot with gts", K(bret), K(first_lsid),
K(snapshot), K(tablet_loc));
}
}
} }
} }
return bret; return bret;

View File

@ -257,7 +257,7 @@ private:
static uint32_t get_real_session_id(ObSQLSessionInfo &session); static uint32_t get_real_session_id(ObSQLSessionInfo &session);
static int get_first_lsid(const ObDASCtx &das_ctx, share::ObLSID &first_lsid); static int get_first_lsid(const ObDASCtx &das_ctx, share::ObLSID &first_lsid);
static bool has_same_lsid(const ObDASCtx &das_ctx, static bool has_same_lsid(const ObDASCtx &das_ctx,
const share::SCN &snapshot_version, const transaction::ObTxReadSnapshot &snapshot,
share::ObLSID &first_lsid); share::ObLSID &first_lsid);
public: public:
/* /*

View File

@ -573,6 +573,16 @@ int ObDupTableLSLeaseMgr::leader_revoke()
return ret; return ret;
} }
bool ObDupTableLSLeaseMgr::is_follower_lease_valid()
{
bool is_follower_lease = false;
SpinRLockGuard guard(lease_lock_);
is_follower_lease = follower_lease_info_.lease_expired_ts_ > ObTimeUtility::current_time();
return is_follower_lease;
}
bool ObDupTableLSLeaseMgr::check_follower_lease_serving(const bool is_election_leader, bool ObDupTableLSLeaseMgr::check_follower_lease_serving(const bool is_election_leader,
const share::SCN &max_replayed_scn) const share::SCN &max_replayed_scn)
{ {

View File

@ -89,6 +89,8 @@ public:
int get_lease_valid_array(LeaseAddrArray &lease_array); int get_lease_valid_array(LeaseAddrArray &lease_array);
bool is_follower_lease_valid();
bool check_follower_lease_serving(const bool election_is_leader, bool check_follower_lease_serving(const bool election_is_leader,
const share::SCN &max_replayed_scn); const share::SCN &max_replayed_scn);

View File

@ -42,7 +42,10 @@ OB_SERIALIZE_MEMBER(DupTabletSetChangeStatus,
need_confirm_scn_, need_confirm_scn_,
readable_version_); readable_version_);
OB_SERIALIZE_MEMBER(DupTabletSetAttribute, common_header_, change_status_); OB_SERIALIZE_MEMBER(DupTabletSetAttribute, common_header_, change_status_);
OB_SERIALIZE_MEMBER(RelatedSetAttribute, related_common_header_, related_change_status_, related_set_type_); OB_SERIALIZE_MEMBER(RelatedSetAttribute,
related_common_header_,
related_change_status_,
related_set_type_);
OB_SERIALIZE_MEMBER(DupTabletLogBody, hash_map_); OB_SERIALIZE_MEMBER(DupTabletLogBody, hash_map_);
//********************************************************************** //**********************************************************************
@ -103,8 +106,8 @@ int ObLSDupTabletsMgr::GcOneReadableSetHandler::operator()(
} else { } else {
if ((gc_ts_ - hash_pair.second.update_dup_schema_ts_) >= tablet_gc_window_) { if ((gc_ts_ - hash_pair.second.update_dup_schema_ts_) >= tablet_gc_window_) {
if (OB_FAIL(old_tablets_.set_refactored(hash_pair.first, hash_pair.second, 1))) { if (OB_FAIL(old_tablets_.set_refactored(hash_pair.first, hash_pair.second, 1))) {
DUP_TABLE_LOG(WARN, "insert into old_tablets_ failed", K(ret), DUP_TABLE_LOG(WARN, "insert into old_tablets_ failed", K(ret), K(hash_pair.first),
K(hash_pair.first), K(hash_pair.second)); K(hash_pair.second));
} else { } else {
gc_tablet_cnt_++; gc_tablet_cnt_++;
if (gc_tablet_cnt_ >= max_gc_tablet_cnt_) { if (gc_tablet_cnt_ >= max_gc_tablet_cnt_) {
@ -113,8 +116,8 @@ int ObLSDupTabletsMgr::GcOneReadableSetHandler::operator()(
} }
} }
// for debug // for debug
DUP_TABLE_LOG(DEBUG, "try copy one tablet from readable set to old", K(ret), DUP_TABLE_LOG(DEBUG, "try copy one tablet from readable set to old", K(ret), K(old_tablets_),
K(old_tablets_), K(gc_ts_), K(hash_pair.second.update_dup_schema_ts_), K(gc_ts_), K(hash_pair.second.update_dup_schema_ts_),
K(gc_ts_ - hash_pair.second.update_dup_schema_ts_), K(tablet_gc_window_), K(gc_ts_ - hash_pair.second.update_dup_schema_ts_), K(tablet_gc_window_),
K(gc_tablet_cnt_), K(max_gc_tablet_cnt_)); K(gc_tablet_cnt_), K(max_gc_tablet_cnt_));
} }
@ -146,12 +149,11 @@ int ObLSDupTabletsMgr::DiagInfoGenerator::operator()(
} }
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
// ret = ::oceanbase::common::databuff_printf(info_buf_, info_buf_len_, info_buf_pos_, // ret = ::oceanbase::common::databuff_printf(info_buf_, info_buf_len_, info_buf_pos_,
// "{ TabletID = %-10lu, RefreshDupSchemaTs = %-20lu} ", // "{ TabletID = %-10lu, RefreshDupSchemaTs = %-20lu}
// hash_pair.first.id(), // ", hash_pair.first.id(),
// hash_pair.second.update_dup_schema_ts_); // hash_pair.second.update_dup_schema_ts_);
ret = ::oceanbase::common::databuff_printf(info_buf_, info_buf_len_, info_buf_pos_, ret = ::oceanbase::common::databuff_printf(info_buf_, info_buf_len_, info_buf_pos_,
"{ TabletID = %-10lu } ", "{ TabletID = %-10lu } ", hash_pair.first.id());
hash_pair.first.id());
} }
iter_count_++; iter_count_++;
@ -195,8 +197,8 @@ int DupTabletChangeMap::create(const uint64_t tenant_id, const int64_t bucket_nu
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
DUP_TABLE_LOG(WARN, "invalid unique_id or tenant_id", K(ret), K(dup_set_attr_), K(tenant_id)); DUP_TABLE_LOG(WARN, "invalid unique_id or tenant_id", K(ret), K(dup_set_attr_), K(tenant_id));
} else if (OB_FAIL(DupTabletIdMap::create(bucket_num, attr))) { } else if (OB_FAIL(DupTabletIdMap::create(bucket_num, attr))) {
DUP_TABLE_LOG(WARN, "create dup tablet id map failed", K(ret), K(dup_set_attr_), DUP_TABLE_LOG(WARN, "create dup tablet id map failed", K(ret), K(dup_set_attr_), K(bucket_num),
K(bucket_num), K(tenant_id)); K(tenant_id));
} }
return ret; return ret;
@ -547,7 +549,7 @@ int ObLSDupTabletsMgr::check_readable(const common::ObTabletID &tablet_id,
return ret; return ret;
} }
int ObLSDupTabletsMgr::find_dup_tablet_in_set(const common::ObTabletID &tablet_id, int ObLSDupTabletsMgr::search_dup_tablet_in_redo_log(const common::ObTabletID &tablet_id,
bool &is_dup_table, bool &is_dup_table,
const share::SCN &from_scn, const share::SCN &from_scn,
const share::SCN &to_scn) const share::SCN &to_scn)
@ -602,8 +604,6 @@ int ObLSDupTabletsMgr::find_dup_tablet_in_set(const common::ObTabletID &tablet_i
ret = OB_SUCCESS; ret = OB_SUCCESS;
} }
} }
new_change_map_ptr = new_change_map_ptr->get_next();
} }
} }
} }
@ -646,6 +646,62 @@ int ObLSDupTabletsMgr::find_dup_tablet_in_set(const common::ObTabletID &tablet_i
return ret; return ret;
} }
int ObLSDupTabletsMgr::search_dup_tablet_for_read(const common::ObTabletID &tablet_id,
bool &is_dup_table)
{
int ret = OB_SUCCESS;
is_dup_table = false;
DupTabletInfo tmp_status;
SpinRLockGuard guard(dup_tablets_lock_);
if (OB_NOT_NULL(changing_new_set_)) {
if (OB_SUCC(changing_new_set_->get_refactored(tablet_id, tmp_status))) {
is_dup_table = true;
} else if (OB_HASH_NOT_EXIST != ret) {
DUP_TABLE_LOG(WARN, "check dup_table old_tablets_ failed", K(ret));
} else {
ret = OB_SUCCESS;
}
}
if (OB_SUCC(ret) && !is_dup_table) {
DupTabletChangeMap *new_change_map_ptr = need_confirm_new_queue_.get_first();
DLIST_FOREACH_X(new_change_map_ptr, need_confirm_new_queue_, !is_dup_table && OB_SUCC(ret))
{
share::SCN tablet_change_scn;
if (OB_ISNULL(new_change_map_ptr->get_change_status())) {
ret = OB_ERR_UNEXPECTED;
DUP_TABLE_LOG(ERROR, "unexpected tablet set type", K(ret), KPC(new_change_map_ptr));
} else if (OB_SUCC(new_change_map_ptr->get_refactored(tablet_id, tmp_status))) {
is_dup_table = true;
} else if (OB_HASH_NOT_EXIST != ret) {
DUP_TABLE_LOG(WARN, "check dup_table new_tablets_ failed", K(ret));
} else {
ret = OB_SUCCESS;
}
}
}
if (OB_SUCC(ret) && !is_dup_table) {
DLIST_FOREACH_X(readable_set_ptr, readable_tablets_list_, !is_dup_table && OB_SUCC(ret))
{
if (OB_SUCC(readable_set_ptr->get_refactored(tablet_id, tmp_status))) {
is_dup_table = true;
} else if (OB_HASH_NOT_EXIST != ret) {
DUP_TABLE_LOG(WARN, "check dup_table old_tablets_ failed", K(ret));
} else {
ret = OB_SUCCESS;
}
}
}
return ret;
}
ERRSIM_POINT_DEF(ERRSIM_DUP_TABLE_GC_RIGHT_NOW); ERRSIM_POINT_DEF(ERRSIM_DUP_TABLE_GC_RIGHT_NOW);
// for gc those not refreshed tablets // for gc those not refreshed tablets
int ObLSDupTabletsMgr::gc_dup_tablets(const int64_t gc_ts, const int64_t max_task_interval) int ObLSDupTabletsMgr::gc_dup_tablets(const int64_t gc_ts, const int64_t max_task_interval)
@ -722,8 +778,7 @@ int ObLSDupTabletsMgr::gc_dup_tablets(const int64_t gc_ts, const int64_t max_tas
} }
} }
} else { } else {
DUP_TABLE_LOG(WARN, "related set type not match", K(ret), DUP_TABLE_LOG(WARN, "related set type not match", K(ret), KPC(removing_old_set_));
KPC(removing_old_set_));
} }
/** /**
@ -780,8 +835,7 @@ DupTabletChangeMap *ObLSDupTabletsMgr::get_need_gc_set_(bool &new_round)
KPC(removing_old_set_), KPC(readable_set_in_gc_)); KPC(removing_old_set_), KPC(readable_set_in_gc_));
readable_set_in_gc_ = nullptr; readable_set_in_gc_ = nullptr;
} else { } else {
while (OB_NOT_NULL(readable_set_in_gc_) while (OB_NOT_NULL(readable_set_in_gc_) && !readable_set_in_gc_->need_gc_scan(gc_start_time_)
&& !readable_set_in_gc_->need_gc_scan(gc_start_time_)
&& readable_set_in_gc_ != readable_tablets_list_.get_header()) { && readable_set_in_gc_ != readable_tablets_list_.get_header()) {
readable_set_in_gc_ = readable_set_in_gc_->get_next(); readable_set_in_gc_ = readable_set_in_gc_->get_next();
} }
@ -816,20 +870,19 @@ int ObLSDupTabletsMgr::scan_readable_set_for_gc()
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
DUP_TABLE_LOG(WARN, "invalid related set type", K(ret), KPC(removing_old_set_)); DUP_TABLE_LOG(WARN, "invalid related set type", K(ret), KPC(removing_old_set_));
} else if (removing_old_set_->get_related_set_op_type() == DupTableRelatedSetOpType::NEW_GC) { } else if (removing_old_set_->get_related_set_op_type() == DupTableRelatedSetOpType::NEW_GC) {
if ((!removing_old_set_->empty()) || if ((!removing_old_set_->empty())
removing_old_set_->get_related_common_header().is_valid()) { || removing_old_set_->get_related_common_header().is_valid()) {
// old set not confimed and clear, not need scan this time // old set not confimed and clear, not need scan this time
} else if (OB_ISNULL(tmp_readable_gc_set_ptr = get_need_gc_set_(new_round))) { } else if (OB_ISNULL(tmp_readable_gc_set_ptr = get_need_gc_set_(new_round))) {
// get null set // get null set
} else { } else {
int64_t cur_time = ObTimeUtility::fast_current_time(); int64_t cur_time = ObTimeUtility::fast_current_time();
if (new_round if (new_round || gc_start_time_ <= 0) {
|| gc_start_time_ <= 0) {
gc_start_time_ = cur_time; gc_start_time_ = cur_time;
} }
GcOneReadableSetHandler gc_handler(cur_time, tablet_gc_window_, GcOneReadableSetHandler gc_handler(cur_time, tablet_gc_window_, *removing_old_set_,
*removing_old_set_, MAX_GC_TABLET_COUNT); MAX_GC_TABLET_COUNT);
if (OB_FAIL(hash_for_each_update(*tmp_readable_gc_set_ptr, gc_handler))) { if (OB_FAIL(hash_for_each_update(*tmp_readable_gc_set_ptr, gc_handler))) {
DUP_TABLE_LOG(WARN, "scan readable for gc failed", K(ret), KPC(removing_old_set_), DUP_TABLE_LOG(WARN, "scan readable for gc failed", K(ret), KPC(removing_old_set_),
KPC(tmp_readable_gc_set_ptr), K(cur_time), K(gc_start_time_)); KPC(tmp_readable_gc_set_ptr), K(cur_time), K(gc_start_time_));
@ -842,14 +895,17 @@ int ObLSDupTabletsMgr::scan_readable_set_for_gc()
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
if (!removing_old_set_->empty()) { if (!removing_old_set_->empty()) {
removing_old_set_->set_related_common_header(tmp_readable_gc_set_ptr->get_common_header()); removing_old_set_->set_related_common_header(
tmp_readable_gc_set_ptr->set_related_set_op_type(DupTableRelatedSetOpType::OPERATED_NEW_GC); tmp_readable_gc_set_ptr->get_common_header());
tmp_readable_gc_set_ptr->set_related_set_op_type(
DupTableRelatedSetOpType::OPERATED_NEW_GC);
} }
} else { } else {
return_tablet_set_(removing_old_set_); return_tablet_set_(removing_old_set_);
} }
DUP_TABLE_LOG(DEBUG, "finish scan readable set", K(ret), K(gc_handler.get_gc_tablet_cnt()), DUP_TABLE_LOG(DEBUG, "finish scan readable set", K(ret), K(gc_handler.get_gc_tablet_cnt()),
KPC(removing_old_set_), KPC(tmp_readable_gc_set_ptr), K(new_round), K(gc_start_time_)); KPC(removing_old_set_), KPC(tmp_readable_gc_set_ptr), K(new_round),
K(gc_start_time_));
} }
} }
@ -890,8 +946,8 @@ int ObLSDupTabletsMgr::remove_tablet_from_readable_set_()
if (OB_TMP_FAIL(related_readable_set->erase_refactored(iter->first))) { if (OB_TMP_FAIL(related_readable_set->erase_refactored(iter->first))) {
if (tmp_ret != OB_HASH_NOT_EXIST) { if (tmp_ret != OB_HASH_NOT_EXIST) {
ret = tmp_ret; ret = tmp_ret;
DUP_TABLE_LOG(WARN, "remove tablet form reabable set failed", K(ret), KPC(related_readable_set), DUP_TABLE_LOG(WARN, "remove tablet form reabable set failed", K(ret),
KPC(removing_old_set_)); KPC(related_readable_set), KPC(removing_old_set_));
} }
} }
} }
@ -902,7 +958,8 @@ int ObLSDupTabletsMgr::remove_tablet_from_readable_set_()
} }
} }
} else { } else {
DUP_TABLE_LOG(WARN, "other related set op type or other status", K(ret), KPC(removing_old_set_)); DUP_TABLE_LOG(WARN, "other related set op type or other status", K(ret),
KPC(removing_old_set_));
} }
return ret; return ret;
@ -960,20 +1017,19 @@ int ObLSDupTabletsMgr::remove_src_and_related_set_header_from_array_(
int64_t i = last_idx; int64_t i = last_idx;
int64_t loop_end_idx = unique_id_array.count() - 2; int64_t loop_end_idx = unique_id_array.count() - 2;
for (; OB_SUCC(ret) && i >=0 && i >= loop_end_idx; i--) { for (; OB_SUCC(ret) && i >= 0 && i >= loop_end_idx; i--) {
if (OB_NOT_NULL(src_set) if (OB_NOT_NULL(src_set) && unique_id_array.at(i) == src_set->get_common_header()) {
&& unique_id_array.at(i) == src_set->get_common_header()) {
if (OB_FAIL(unique_id_array.remove(i))) { if (OB_FAIL(unique_id_array.remove(i))) {
DUP_TABLE_LOG(INFO, "remove src set header from array failed", K(last_idx), K(i), K(unique_id_array), DUP_TABLE_LOG(INFO, "remove src set header from array failed", K(last_idx), K(i),
KPC(src_set)); K(unique_id_array), KPC(src_set));
} else { } else {
src_set->clean_logging(); src_set->clean_logging();
} }
} else if (OB_NOT_NULL(related_set) } else if (OB_NOT_NULL(related_set)
&& unique_id_array.at(i) == related_set->get_common_header()) { && unique_id_array.at(i) == related_set->get_common_header()) {
if (OB_FAIL(unique_id_array.remove(i))) { if (OB_FAIL(unique_id_array.remove(i))) {
DUP_TABLE_LOG(INFO, "remove related set header from array failed", K(last_idx), K(i), K(unique_id_array), DUP_TABLE_LOG(INFO, "remove related set header from array failed", K(last_idx), K(i),
KPC(src_set)); K(unique_id_array), KPC(src_set));
} else { } else {
related_set->clean_logging(); related_set->clean_logging();
} }
@ -987,7 +1043,8 @@ int ObLSDupTabletsMgr::remove_src_and_related_set_header_from_array_(
return ret; return ret;
} }
int ObLSDupTabletsMgr::prepare_serialize_src_set_with_related_set_(DupTabletChangeMap *src_set, int ObLSDupTabletsMgr::prepare_serialize_src_set_with_related_set_(
DupTabletChangeMap *src_set,
int64_t &max_ser_size, int64_t &max_ser_size,
const int64_t max_log_buf_len, const int64_t max_log_buf_len,
DupTabletSetIDArray &unique_id_array, DupTabletSetIDArray &unique_id_array,
@ -1002,22 +1059,24 @@ int ObLSDupTabletsMgr::prepare_serialize_src_set_with_related_set_(DupTabletChan
DUP_TABLE_LOG(WARN, "invalid related set type", K(ret), KPC(src_set)); DUP_TABLE_LOG(WARN, "invalid related set type", K(ret), KPC(src_set));
} else if (src_set->get_related_set_op_type() == DupTableRelatedSetOpType::NEW_GC) { } else if (src_set->get_related_set_op_type() == DupTableRelatedSetOpType::NEW_GC) {
// prepare serialize related readable set for new gc // prepare serialize related readable set for new gc
if (OB_FAIL(cal_single_set_max_ser_size_(src_set, max_ser_size, if (OB_FAIL(cal_single_set_max_ser_size_(src_set, max_ser_size, max_log_buf_len,
max_log_buf_len, unique_id_array))) { unique_id_array))) {
DUP_TABLE_LOG(WARN, "ser src set failed", K(ret), KPC(src_set), KPC(related_set)); DUP_TABLE_LOG(WARN, "ser src set failed", K(ret), KPC(src_set), KPC(related_set));
if (OB_SIZE_OVERFLOW == ret) { if (OB_SIZE_OVERFLOW == ret) {
ret = OB_LOG_TOO_LARGE; ret = OB_LOG_TOO_LARGE;
} }
} else if (OB_FALSE_IT(src_set->set_logging())) { } else if (OB_FALSE_IT(src_set->set_logging())) {
} else if (OB_FAIL(get_target_tablet_set_(src_set->get_related_common_header(), related_set))) { } else if (OB_FAIL(
get_target_tablet_set_(src_set->get_related_common_header(), related_set))) {
DUP_TABLE_LOG(WARN, "get related set failed", K(ret), KPC(src_set), KPC(related_set)); DUP_TABLE_LOG(WARN, "get related set failed", K(ret), KPC(src_set), KPC(related_set));
if (ret == OB_ENTRY_NOT_EXIST) { if (ret == OB_ENTRY_NOT_EXIST) {
// related set recycled, old set not confirmed, rewrite ret code to log old set to confirm // related set recycled, old set not confirmed, rewrite ret code to log old set to confirm
ret = OB_SUCCESS; ret = OB_SUCCESS;
} }
} else if (OB_FAIL(cal_single_set_max_ser_size_(related_set, max_ser_size, } else if (OB_FAIL(cal_single_set_max_ser_size_(related_set, max_ser_size, max_log_buf_len,
max_log_buf_len, unique_id_array))) { unique_id_array))) {
DUP_TABLE_LOG(WARN, "cal related set se size falied", K(ret), K(max_ser_size), KPC(src_set), KPC(related_set)); DUP_TABLE_LOG(WARN, "cal related set se size falied", K(ret), K(max_ser_size), KPC(src_set),
KPC(related_set));
if (OB_SIZE_OVERFLOW == ret) { if (OB_SIZE_OVERFLOW == ret) {
ret = OB_LOG_TOO_LARGE; ret = OB_LOG_TOO_LARGE;
} }
@ -1026,8 +1085,7 @@ int ObLSDupTabletsMgr::prepare_serialize_src_set_with_related_set_(DupTabletChan
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
// if failed, remove ser header from array // if failed, remove ser header from array
if (OB_TMP_FAIL(remove_src_and_related_set_header_from_array_(src_set, if (OB_TMP_FAIL(remove_src_and_related_set_header_from_array_(src_set, related_set,
related_set,
unique_id_array))) { unique_id_array))) {
ret = tmp_ret; ret = tmp_ret;
DUP_TABLE_LOG(WARN, "remove src and related header failed", K(ret), K(max_ser_size), DUP_TABLE_LOG(WARN, "remove src and related header failed", K(ret), K(max_ser_size),
@ -1446,8 +1504,7 @@ int ObLSDupTabletsMgr::tablet_log_synced(const bool sync_result,
if (OB_FAIL(try_exec_special_op_(logging_tablet_set, scn, for_replay))) { if (OB_FAIL(try_exec_special_op_(logging_tablet_set, scn, for_replay))) {
DUP_TABLE_LOG(WARN, "try to execute special opertion for dup tablet set", K(ret), DUP_TABLE_LOG(WARN, "try to execute special opertion for dup tablet set", K(ret),
KPC(logging_tablet_set)); KPC(logging_tablet_set));
} else if(logging_common_header.need_clean_all_readable_set()) } else if (logging_common_header.need_clean_all_readable_set()) {
{
clean_readable = true; clean_readable = true;
} }
@ -1472,8 +1529,7 @@ int ObLSDupTabletsMgr::tablet_log_synced(const bool sync_result,
if (OB_SUCC(ret) && sync_result) { if (OB_SUCC(ret) && sync_result) {
// if old is confirmed, clear it // if old is confirmed, clear it
if (logging_common_header.is_old_set()) { if (logging_common_header.is_old_set()) {
DUP_TABLE_LOG(DEBUG, "clean old set", K(ret), DUP_TABLE_LOG(DEBUG, "clean old set", K(ret), KPC(logging_tablet_set), K(for_replay));
KPC(logging_tablet_set), K(for_replay));
return_tablet_set_(logging_tablet_set); return_tablet_set_(logging_tablet_set);
// move need_confirm_queue to readable // move need_confirm_queue to readable
} else if (OB_FAIL(merge_into_readable_tablets_(logging_tablet_set, for_replay))) { } else if (OB_FAIL(merge_into_readable_tablets_(logging_tablet_set, for_replay))) {
@ -1718,7 +1774,7 @@ bool ObLSDupTabletsMgr::check_removing_tablet_exist()
bool_ret = false; bool_ret = false;
} else if (removing_old_set_->size() > 0) { } else if (removing_old_set_->size() > 0) {
bool_ret = true; bool_ret = true;
} else if (!removing_old_set_->get_change_status()->is_modifiable()){ } else if (!removing_old_set_->get_change_status()->is_modifiable()) {
bool_ret = true; bool_ret = true;
} else { } else {
bool_ret = false; bool_ret = false;
@ -2004,7 +2060,8 @@ void ObLSDupTabletsMgr::print_tablet_diag_info_log(bool is_master)
} }
} }
tablet_set_diag_info_log_buf_[MIN(tablet_set_diag_pos + 1, TABLET_SET_PRINT_BUF_LEN - 1)] = '\0'; tablet_set_diag_info_log_buf_[MIN(tablet_set_diag_pos + 1, TABLET_SET_PRINT_BUF_LEN - 1)] =
'\0';
tablet_id_diag_info_log_buf_[MIN(tablet_id_diag_pos + 1, TABLET_ID_PRINT_BUF_LEN - 1)] = '\0'; tablet_id_diag_info_log_buf_[MIN(tablet_id_diag_pos + 1, TABLET_ID_PRINT_BUF_LEN - 1)] = '\0';
_DUP_TABLE_LOG( _DUP_TABLE_LOG(
INFO, INFO,
@ -2173,11 +2230,11 @@ int ObLSDupTabletsMgr::discover_dup_tablet_(const common::ObTabletID &tablet_id,
changing_new_set_header.set_invalid_unique_id(); changing_new_set_header.set_invalid_unique_id();
changing_new_set_header.set_new(); changing_new_set_header.set_new();
DupTabletChangeMap *changing_new_map = nullptr; DupTabletChangeMap *changing_new_map = nullptr;
int64_t rmoving_tablet_cnt = OB_NOT_NULL(old_tablets_ptr) int64_t rmoving_tablet_cnt = OB_NOT_NULL(old_tablets_ptr) ? old_tablets_ptr->size() : 0;
? old_tablets_ptr->size() : 0;
if (OB_FAIL(get_target_tablet_set_(changing_new_set_header, changing_new_map))) { if (OB_FAIL(get_target_tablet_set_(changing_new_set_header, changing_new_map))) {
DUP_TABLE_LOG(WARN, "get changing new set failed", K(ret), KPC(changing_new_map)); DUP_TABLE_LOG(WARN, "get changing new set failed", K(ret), KPC(changing_new_map));
} else if (confirming_tablet_cnt + changing_new_map->size() + rmoving_tablet_cnt > MAX_CONFIRMING_TABLET_COUNT } else if (confirming_tablet_cnt + changing_new_map->size() + rmoving_tablet_cnt
> MAX_CONFIRMING_TABLET_COUNT
|| contain_confirming_special_op) { || contain_confirming_special_op) {
DUP_TABLE_LOG( DUP_TABLE_LOG(
INFO, INFO,
@ -2544,8 +2601,8 @@ int ObLSDupTabletsMgr::clean_durable_confirming_tablets_(const share::SCN &min_r
DLIST_FOREACH_REMOVESAFE(need_confirm_set, need_confirm_new_queue_) DLIST_FOREACH_REMOVESAFE(need_confirm_set, need_confirm_new_queue_)
{ {
DUP_TABLE_LOG(INFO, "try to clean one confirming tablet set", K(ret), K(min_reserve_tablet_scn), DUP_TABLE_LOG(INFO, "try to clean one confirming tablet set", K(ret),
KPC(need_confirm_set)); K(min_reserve_tablet_scn), KPC(need_confirm_set));
if (!need_confirm_set->need_reserve(min_reserve_tablet_scn)) { if (!need_confirm_set->need_reserve(min_reserve_tablet_scn)) {
if (OB_ISNULL(need_confirm_new_queue_.remove(need_confirm_set))) { if (OB_ISNULL(need_confirm_new_queue_.remove(need_confirm_set))) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
@ -2643,7 +2700,8 @@ int ObLSDupTabletsMgr::construct_empty_block_confirm_task_(const int64_t trx_ref
K(ret), KPC(block_confirm_task)); K(ret), KPC(block_confirm_task));
} }
if (OB_TMP_FAIL(return_tablet_set_(block_confirm_task))) { if (OB_TMP_FAIL(return_tablet_set_(block_confirm_task))) {
DUP_TABLE_LOG(WARN, "return block_confirm_task failed", K(tmp_ret), KPC(block_confirm_task)); DUP_TABLE_LOG(WARN, "return block_confirm_task failed", K(tmp_ret),
KPC(block_confirm_task));
} }
} }
} else { } else {

View File

@ -602,9 +602,10 @@ public:
bool &readable, bool &readable,
const share::SCN &snapshot, const share::SCN &snapshot,
DupTableInterfaceStat interface_stat); DupTableInterfaceStat interface_stat);
int search_dup_tablet_for_read(const common::ObTabletID &tablet_id, bool &is_dup_table);
// For part_ctx, check_dup_table will be invoked after submit_log in LS which has dup_table // For part_ctx, check_dup_table will be invoked after submit_log in LS which has dup_table
// tablets. It will bring performance effect for normal part_ctx without dup_table tablets. // tablets. It will bring performance effect for normal part_ctx without dup_table tablets.
int find_dup_tablet_in_set(const common::ObTabletID &tablet_id, int search_dup_tablet_in_redo_log(const common::ObTabletID &tablet_id,
bool &is_dup_table, bool &is_dup_table,
const share::SCN &from_scn, const share::SCN &from_scn,
const share::SCN &to_scn); const share::SCN &to_scn);

View File

@ -1058,7 +1058,7 @@ int ObDupTableLSHandler::check_dup_tablet_in_redo(const ObTabletID &tablet_id,
is_dup_tablet = false; is_dup_tablet = false;
} else if (!has_dup_tablet()) { } else if (!has_dup_tablet()) {
is_dup_tablet = false; is_dup_tablet = false;
} else if (OB_FAIL(tablets_mgr_ptr_->find_dup_tablet_in_set(tablet_id, is_dup_tablet, } else if (OB_FAIL(tablets_mgr_ptr_->search_dup_tablet_in_redo_log(tablet_id, is_dup_tablet,
base_snapshot, redo_scn))) { base_snapshot, redo_scn))) {
DUP_TABLE_LOG(WARN, "check dup tablet failed", K(ret), K(tablet_id), K(base_snapshot), DUP_TABLE_LOG(WARN, "check dup tablet failed", K(ret), K(tablet_id), K(base_snapshot),
K(redo_scn)); K(redo_scn));
@ -1120,6 +1120,28 @@ int ObDupTableLSHandler::check_dup_tablet_readable(const ObTabletID &tablet_id,
return ret; return ret;
} }
bool ObDupTableLSHandler::is_dup_table_lease_valid()
{
bool is_dup_lease_ls = false;
const bool is_election_leader = false;
if (has_dup_tablet()) {
if (OB_ISNULL(lease_mgr_ptr_)) {
is_dup_lease_ls = false;
} else if (ls_state_helper_.is_leader()) {
is_dup_lease_ls = true;
DUP_TABLE_LOG(INFO, "the lease is always valid for a dup ls leader", K(is_dup_lease_ls),
KPC(this));
} else {
is_dup_lease_ls = lease_mgr_ptr_->is_follower_lease_valid();
}
} else {
is_dup_lease_ls = false;
}
return is_dup_lease_ls;
}
int64_t ObDupTableLSHandler::get_dup_tablet_count() int64_t ObDupTableLSHandler::get_dup_tablet_count()
{ {
int64_t dup_tablet_cnt = 0; int64_t dup_tablet_cnt = 0;
@ -1144,6 +1166,24 @@ bool ObDupTableLSHandler::has_dup_tablet()
return has_dup; return has_dup;
} }
bool ObDupTableLSHandler::is_dup_tablet(const common::ObTabletID &tablet_id)
{
bool is_dup_tablet = false;
int ret = OB_SUCCESS;
if (!tablet_id.is_valid()) {
ret = OB_INVALID_ARGUMENT;
DUP_TABLE_LOG(WARN, "invalid argument", K(ret), K(tablet_id));
} else if (OB_ISNULL(tablets_mgr_ptr_)) {
is_dup_tablet = false;
} else if (OB_FAIL(tablets_mgr_ptr_->search_dup_tablet_for_read(tablet_id, is_dup_tablet))) {
DUP_TABLE_LOG(WARN, "check dup tablet failed", K(ret), K(tablet_id), K(is_dup_tablet));
is_dup_tablet = false;
}
return is_dup_tablet;
}
// if return false, there are no tablets and tablet set need log // if return false, there are no tablets and tablet set need log
bool ObDupTableLSHandler::check_tablet_set_exist() bool ObDupTableLSHandler::check_tablet_set_exist()
{ {

View File

@ -177,10 +177,13 @@ public:
const share::SCN &max_replayed_scn, const share::SCN &max_replayed_scn,
bool &readable); bool &readable);
bool is_dup_table_lease_valid();
public: public:
int64_t get_dup_tablet_count(); int64_t get_dup_tablet_count();
bool check_tablet_set_exist(); bool check_tablet_set_exist();
bool has_dup_tablet(); bool has_dup_tablet();
bool is_dup_tablet(const common::ObTabletID &tablet_id);
int gc_dup_tablets(const int64_t gc_ts, const int64_t max_task_interval); int gc_dup_tablets(const int64_t gc_ts, const int64_t max_task_interval);
int get_local_ts_info(DupTableTsInfo &ts_info); int get_local_ts_info(DupTableTsInfo &ts_info);
int get_cache_ts_info(const common::ObAddr &addr, DupTableTsInfo &ts_info); int get_cache_ts_info(const common::ObAddr &addr, DupTableTsInfo &ts_info);

View File

@ -31,6 +31,7 @@
#include "wrs/ob_weak_read_util.h" // ObWeakReadUtil #include "wrs/ob_weak_read_util.h" // ObWeakReadUtil
#include "storage/memtable/ob_memtable_context.h" #include "storage/memtable/ob_memtable_context.h"
#include "storage/memtable/ob_memtable.h" #include "storage/memtable/ob_memtable.h"
#include "storage/tx_storage/ob_ls_service.h"
#include "common/storage/ob_sequence.h" #include "common/storage/ob_sequence.h"
#include "observer/ob_srv_network_frame.h" #include "observer/ob_srv_network_frame.h"
#include "share/rc/ob_tenant_module_init_ctx.h" #include "share/rc/ob_tenant_module_init_ctx.h"
@ -613,6 +614,38 @@ int ObTransService::get_max_decided_scn(const share::ObLSID &ls_id, share::SCN &
return ret; return ret;
} }
int ObTransService::check_dup_table_lease_valid(const ObLSID ls_id,
bool &is_dup_ls,
bool &is_lease_valid)
{
int ret = OB_SUCCESS;
ObLSHandle ls_handle;
is_dup_ls = false;
is_lease_valid = false;
if (!ls_id.is_valid()) {
ret = OB_INVALID_ARGUMENT;
TRANS_LOG(WARN, "invalid argument", K(ret), K(ls_id));
} else if (!dup_table_loop_worker_.is_useful_dup_ls(ls_id)) {
is_dup_ls = false;
ret = OB_SUCCESS;
} else if (OB_FAIL(MTL(ObLSService *)->get_ls(ls_id, ls_handle, ObLSGetMod::TRANS_MOD))) {
is_dup_ls = false;
TRANS_LOG(WARN, "get ls failed", K(ret), K(ls_id), K(ls_handle));
} else if (!ls_handle.is_valid()) {
is_dup_ls = false;
ret = OB_ERR_UNEXPECTED;
TRANS_LOG(WARN, "invalid ls handle", K(ret), K(ls_id), K(ls_handle));
} else if (ls_handle.get_ls()->get_dup_table_ls_handler()->is_dup_table_lease_valid()) {
is_dup_ls = true;
is_lease_valid = true;
ret = OB_SUCCESS;
}
return ret;
}
int ObTransService::handle_redo_sync_task_(ObDupTableRedoSyncTask *task, bool &need_release_task) int ObTransService::handle_redo_sync_task_(ObDupTableRedoSyncTask *task, bool &need_release_task)
{ {
UNUSED(task); UNUSED(task);

View File

@ -174,6 +174,7 @@ public:
int calculate_trans_cost(const ObTransID &tid, uint64_t &cost); int calculate_trans_cost(const ObTransID &tid, uint64_t &cost);
int get_ls_min_uncommit_prepare_version(const share::ObLSID &ls_id, share::SCN &min_prepare_version); int get_ls_min_uncommit_prepare_version(const share::ObLSID &ls_id, share::SCN &min_prepare_version);
int get_min_undecided_log_ts(const share::ObLSID &ls_id, share::SCN &log_ts); int get_min_undecided_log_ts(const share::ObLSID &ls_id, share::SCN &log_ts);
int check_dup_table_lease_valid(const ObLSID ls_id, bool &is_dup_ls, bool &is_lease_valid);
//get the memory used condition of transaction module //get the memory used condition of transaction module
int iterate_trans_memory_stat(ObTransMemStatIterator &mem_stat_iter); int iterate_trans_memory_stat(ObTransMemStatIterator &mem_stat_iter);
int dump_elr_statistic(); int dump_elr_statistic();

View File

@ -1453,40 +1453,6 @@ int ObTransService::check_replica_readable_(const ObTxReadSnapshot &snapshot,
} }
} }
if (OB_SUCC(ret) && !dup_table_readable && ObTxReadSnapshot::SRC::LS == src
&& ObRole::FOLLOWER == snapshot.snapshot_ls_role_) {
int tmp_ret = OB_SUCCESS;
if (readable) {
if (OB_TMP_FAIL(ls.get_tx_svr()->get_tx_ls_log_adapter()->get_role(leader, epoch))) {
TRANS_LOG(WARN, "get replica status fail", K(tmp_ret), K(ls_id));
} else if (leader) {
tmp_ret = OB_SUCCESS;
} else if (OB_TMP_FAIL(ls.get_max_decided_scn(max_replayed_scn))) {
TRANS_LOG(WARN, "get max decided scn failed", K(ret), K(tmp_ret), K(ls_id));
// rewrite ret code when get max decided scn failed
tmp_ret = OB_NOT_MASTER;
} else if (OB_TMP_FAIL(ls.get_tx_svr()->get_tx_ls_log_adapter()->check_dup_tablet_readable(
tablet_id, snapshot.core_.version_, leader, max_replayed_scn,
dup_table_readable))) {
TRANS_LOG(WARN, "check dup tablet readable error", K(ret), K(tmp_ret));
} else if (dup_table_readable) {
TRANS_LOG(INFO, "the dup tablet is readable with the max_commit_ts from a follower", K(ret),
K(tmp_ret), K(tablet_id), K(snapshot), K(leader), K(max_replayed_scn),
K(dup_table_readable), K(ls_id), K(expire_ts));
tmp_ret = OB_SUCCESS;
}
}
if (tmp_ret == OB_SUCCESS && dup_table_readable) {
// do nothing
} else {
ret = OB_NOT_MASTER;
TRANS_LOG(WARN, "we can not use a max_commit_ts from the follower", K(ret), K(tablet_id),
K(snapshot), K(leader), K(max_replayed_scn), K(dup_table_readable), K(ls_id),
K(expire_ts), K(MTL_IS_PRIMARY_TENANT()));
}
}
TRANS_LOG(TRACE, "check replica readable", K(ret), K(snapshot), K(ls_id)); TRANS_LOG(TRACE, "check replica readable", K(ret), K(snapshot), K(ls_id));
return ret; return ret;
} }
@ -1641,9 +1607,9 @@ int ObTransService::acquire_local_snapshot_(const share::ObLSID &ls_id,
ls_tx_ctx_mgr->get_ls_log_adapter()->get_committing_dup_trx_cnt(); ls_tx_ctx_mgr->get_ls_log_adapter()->get_committing_dup_trx_cnt();
if (!MTL_IS_PRIMARY_TENANT()) { if (!MTL_IS_PRIMARY_TENANT()) {
ret = OB_NOT_MASTER; ret = OB_NOT_MASTER;
TRANS_LOG(WARN, "the max_commmit_ts can not be used as a snapshot in standby tenant ", K(ret), TRANS_LOG(DEBUG, "the max_commmit_ts can not be used as a snapshot in standby tenant ", K(ret),
K(ls_id), K(snapshot), K(MTL_IS_PRIMARY_TENANT()), K(committing_dup_trx_cnt)); K(ls_id), K(snapshot), K(MTL_IS_PRIMARY_TENANT()), K(committing_dup_trx_cnt));
} else if (!MTL(ObTransService*)->get_dup_table_loop_worker().is_useful_dup_ls(ls_id)) { } else if (!ls_tx_ctx_mgr->get_ls_log_adapter()->is_dup_table_lease_valid()) {
ret = OB_NOT_MASTER; ret = OB_NOT_MASTER;
} else if (committing_dup_trx_cnt > 0) { } else if (committing_dup_trx_cnt > 0) {
ret = OB_NOT_MASTER; ret = OB_NOT_MASTER;
@ -1676,7 +1642,7 @@ int ObTransService::acquire_local_snapshot_(const share::ObLSID &ls_id,
// | count == 0 // | count == 0
// v // v
// +----------------+ false +----------------------------------------------------------------+ // +----------------+ false +----------------------------------------------------------------+
// | Not Master | <----------- | check_replica_readable : read a dup table tablet on a follower | // | Not Master | <----------- | check all tablet loc: all tablet is dup table tablet |
// +----------------+ +----------------------------------------------------------------+ // +----------------+ +----------------------------------------------------------------+
// | // |
// | true // | true

View File

@ -253,6 +253,19 @@ int ObLSTxLogAdapter::check_redo_sync_completed(const ObTransID &tx_id,
return ret; return ret;
} }
bool ObLSTxLogAdapter::is_dup_table_lease_valid()
{
bool is_follower_lease = false;
if (OB_ISNULL(dup_table_ls_handler_)) {
DUP_TABLE_LOG_RET(WARN, OB_ERR_UNEXPECTED, "invalid dup table ls handler");
} else {
is_follower_lease = dup_table_ls_handler_->is_dup_table_lease_valid();
}
return is_follower_lease;
}
bool ObLSTxLogAdapter::has_dup_tablet() bool ObLSTxLogAdapter::has_dup_tablet()
{ {
bool has_dup = false; bool has_dup = false;

View File

@ -86,6 +86,7 @@ public:
const share::SCN &redo_completed_scn, const share::SCN &redo_completed_scn,
bool &redo_sync_finish, bool &redo_sync_finish,
share::SCN &total_max_read_version); share::SCN &total_max_read_version);
virtual bool is_dup_table_lease_valid() { return false; }
virtual bool has_dup_tablet() { return false; } virtual bool has_dup_tablet() { return false; }
virtual int64_t get_committing_dup_trx_cnt(); virtual int64_t get_committing_dup_trx_cnt();
virtual int add_commiting_dup_trx(const ObTransID &tx_id); virtual int add_commiting_dup_trx(const ObTransID &tx_id);
@ -127,6 +128,7 @@ public:
const share::SCN &redo_completed_scn, const share::SCN &redo_completed_scn,
bool &redo_sync_finish, bool &redo_sync_finish,
share::SCN &total_max_read_version); share::SCN &total_max_read_version);
bool is_dup_table_lease_valid();
bool has_dup_tablet(); bool has_dup_tablet();
int64_t get_committing_dup_trx_cnt(); int64_t get_committing_dup_trx_cnt();
int add_commiting_dup_trx(const ObTransID &tx_id); int add_commiting_dup_trx(const ObTransID &tx_id);