[scn] fix failure of mittest after refresh feature scn

This commit is contained in:
obdev
2022-11-28 01:46:42 +00:00
committed by ob-robot
parent 49a02f3304
commit 54b64a7263
1898 changed files with 255804 additions and 280809 deletions

View File

@ -23,6 +23,8 @@ namespace oceanbase
{
namespace share
{
using namespace oceanbase::palf;
template <typename T>
T first_param_percnetage(const T first, const T second)
{
@ -37,42 +39,108 @@ T first_param_percnetage(const T first, const T second)
ObMergeInfoItem::ObMergeInfoItem(
ObMergeInfoItem::ItemList &list,
const char *name,
int64_t value,
const SCN &scn,
const bool need_update)
: name_(name), value_(value < 0 ? 0 : value), need_update_(need_update)
: name_(name), is_scn_(true), scn_(scn),
value_(-1), need_update_(need_update)
{
list.add_last(this);
}
ObMergeInfoItem::ObMergeInfoItem(
ObMergeInfoItem::ItemList &list,
const char *name,
const int64_t value,
const bool need_update)
: name_(name), is_scn_(false), scn_(),
value_(value), need_update_(need_update)
{
list.add_last(this);
}
ObMergeInfoItem::ObMergeInfoItem(const ObMergeInfoItem &item)
: name_(item.name_), value_(item.value_), need_update_(item.need_update_)
: name_(item.name_), is_scn_(item.is_scn_), scn_(),
value_(item.value_), need_update_(item.need_update_)
{
scn_ = item.scn_;
}
bool ObMergeInfoItem::is_valid() const
{
bool is_valid = false;
if (is_scn_) {
is_valid = scn_.is_valid();
} else {
is_valid = (value_ >= 0);
}
return is_valid && (NULL != name_);
}
void ObMergeInfoItem::assign_value(const ObMergeInfoItem &item)
{
name_ = item.name_;
is_scn_ = item.is_scn_;
scn_ = item.scn_;
value_ = item.value_;
}
void ObMergeInfoItem::set_val(const int64_t value, const bool need_update)
{
is_scn_ = false;
value_ = ((value < 0) ? 0: value);
need_update_ = need_update;
}
void ObMergeInfoItem::set_scn(const SCN &scn, const bool need_update)
{
is_scn_ = true;
scn_ = scn;
need_update_ = need_update;
}
int ObMergeInfoItem::set_scn(const uint64_t scn_val)
{
int ret = OB_SUCCESS;
is_scn_ = true;
if (OB_FAIL(scn_.convert_for_inner_table_field(scn_val))) {
LOG_WARN("fail to convert uint64_t to SCN", KR(ret), K(scn_val));
}
return ret;
}
int ObMergeInfoItem::set_scn(const uint64_t scn_val, const bool need_update)
{
int ret = OB_SUCCESS;
if (OB_FAIL(set_scn(scn_val))) {
LOG_WARN("fail to set scn val", KR(ret), K(scn_val));
} else {
need_update_ = need_update;
}
return ret;
}
ObMergeInfoItem &ObMergeInfoItem::operator =(const ObMergeInfoItem &item)
{
name_ = item.name_;
is_scn_ = item.is_scn_;
scn_ = item.scn_;
value_ = item.value_;
need_update_ = item.need_update_;
return *this;
}
///////////////////////////////////////////////////////////////////////////////
#define INIT_ITEM(field, int_def, update_def) field##_(list_, #field, int_def, update_def)
#define INIT_VAL_ITEM(field, int_def, update_def) field##_(list_, #field, int_def, update_def)
#define INIT_SCN_ITEM(field, scn_def, update_def) field##_(list_, #field, scn_def, update_def)
///////////////////////////////////////////////////////////////////////////////
#define CONSTRUCT_ZONE_MERGE_INFO() \
INIT_ITEM(is_merging, 0, false), \
INIT_ITEM(broadcast_scn, 1, false), \
INIT_ITEM(last_merged_scn, OB_MERGED_VERSION_INIT, false),\
INIT_ITEM(last_merged_time, 0, false), \
INIT_ITEM(all_merged_scn, 1, false), \
INIT_ITEM(merge_start_time, 0, false), \
INIT_ITEM(merge_status, 0, false), \
INIT_ITEM(frozen_scn, 1, false)
INIT_VAL_ITEM(is_merging, 0, false), \
INIT_SCN_ITEM(broadcast_scn, SCN::base_scn(), false), \
INIT_SCN_ITEM(last_merged_scn, SCN::base_scn(), false), \
INIT_VAL_ITEM(last_merged_time, 0, false), \
INIT_SCN_ITEM(all_merged_scn, SCN::base_scn(), false), \
INIT_VAL_ITEM(merge_start_time, 0, false), \
INIT_VAL_ITEM(merge_status, 0, false), \
INIT_SCN_ITEM(frozen_scn, SCN::base_scn(), false)
ObZoneMergeInfo::ObZoneMergeInfo()
: tenant_id_(OB_INVALID_TENANT_ID),
@ -163,18 +231,18 @@ ObZoneMergeInfo::MergeStatus ObZoneMergeInfo::get_merge_status(const char* merge
bool ObZoneMergeInfo::is_merged(const int64_t broadcast_version) const
{
return (broadcast_version == broadcast_scn_)
&& (broadcast_scn_ == last_merged_scn_);
return (broadcast_version == broadcast_scn_.get_scn_val())
&& (broadcast_scn_.get_scn_val() == last_merged_scn_.get_scn_val());
}
bool ObZoneMergeInfo::is_valid() const
{
bool is_valid = true;
if ((broadcast_scn_ < 0)
|| (last_merged_scn_ < 0)
|| (last_merged_time_ < 0)
|| (merge_start_time_ < 0)
|| (all_merged_scn_ < 0)) {
if ((!broadcast_scn_.is_valid())
|| (!last_merged_scn_.is_valid())
|| (last_merged_time_.get_value() < 0)
|| (merge_start_time_.get_value() < 0)
|| (!all_merged_scn_.is_valid())) {
is_valid = false;
}
return is_valid;
@ -182,21 +250,21 @@ bool ObZoneMergeInfo::is_valid() const
bool ObZoneMergeInfo::is_in_merge() const
{
return is_merging_;
return is_merging_.get_value();
}
///////////////////////////////////////////////////////////////////////////////
#define CONSTRUCT_GLOBAL_MERGE_INFO() \
INIT_ITEM(cluster, 0, false), \
INIT_ITEM(frozen_scn, 1, false), \
INIT_ITEM(global_broadcast_scn, 1, false), \
INIT_ITEM(last_merged_scn, 1, false), \
INIT_ITEM(is_merge_error, 0, false), \
INIT_ITEM(merge_status, 0, false), \
INIT_ITEM(error_type, 0, false), \
INIT_ITEM(suspend_merging, 0, false), \
INIT_ITEM(merge_start_time, 0, false), \
INIT_ITEM(last_merged_time, 0, false)
INIT_VAL_ITEM(cluster, 0, false), \
INIT_SCN_ITEM(frozen_scn, SCN::base_scn(), false), \
INIT_SCN_ITEM(global_broadcast_scn, SCN::base_scn(), false), \
INIT_SCN_ITEM(last_merged_scn, SCN::base_scn(), false), \
INIT_VAL_ITEM(is_merge_error, 0, false), \
INIT_VAL_ITEM(merge_status, 0, false), \
INIT_VAL_ITEM(error_type, 0, false), \
INIT_VAL_ITEM(suspend_merging, 0, false), \
INIT_VAL_ITEM(merge_start_time, 0, false), \
INIT_VAL_ITEM(last_merged_time, 0, false)
ObGlobalMergeInfo::ObGlobalMergeInfo()
: tenant_id_(OB_INVALID_TENANT_ID),
@ -212,32 +280,27 @@ void ObGlobalMergeInfo::reset()
bool ObGlobalMergeInfo::is_last_merge_complete() const
{
return last_merged_scn_ == global_broadcast_scn_;
return last_merged_scn() == global_broadcast_scn();
}
bool ObGlobalMergeInfo::is_in_merge() const
{
return (last_merged_scn_ != global_broadcast_scn_)
&& (!suspend_merging_);
return (last_merged_scn() != global_broadcast_scn())
&& (0 == suspend_merging_.get_value());
}
bool ObGlobalMergeInfo::is_merge_error() const
{
return (is_merge_error_ > 0);
}
bool ObGlobalMergeInfo::is_in_verifying_status() const
{
return (ObZoneMergeInfo::MERGE_STATUS_VERIFYING == merge_status_);
return (is_merge_error_.get_value() > 0);
}
bool ObGlobalMergeInfo::is_valid() const
{
bool is_valid = true;
if ((OB_INVALID_TENANT_ID == tenant_id_)
|| (frozen_scn_ < 0)
|| (global_broadcast_scn_ < 0)
|| (last_merged_scn_ < 0)) {
|| (!frozen_scn_.is_valid())
|| (!global_broadcast_scn_.is_valid())
|| (!last_merged_scn_.is_valid())) {
is_valid = false;
}
return is_valid;