add log of load freeze_info/global_merge_info/zone_merge_info and defence of scn_revert
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
#include "share/ob_cluster_version.h"
|
||||
#include "share/inner_table/ob_inner_table_schema_constants.h"
|
||||
#include "share/ob_service_epoch_proxy.h"
|
||||
#include "lib/container/ob_array_wrap.h"
|
||||
#include "lib/mysqlclient/ob_mysql_proxy.h"
|
||||
#include "lib/utility/ob_macro_utils.h"
|
||||
#include "rootserver/ob_rs_event_history_table_operator.h"
|
||||
@ -71,7 +72,8 @@ int ObZoneMergeManagerBase::reload()
|
||||
LOG_WARN("not init", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(tmp_merge_infos.init())) {
|
||||
LOG_WARN("fail to alloc temp zone merge infos", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(ObGlobalMergeTableOperator::load_global_merge_info(*proxy_, tenant_id_, global_merge_info))) {
|
||||
} else if (OB_FAIL(ObGlobalMergeTableOperator::load_global_merge_info(*proxy_, tenant_id_,
|
||||
global_merge_info, true/*print_sql*/))) {
|
||||
LOG_WARN("fail to get global merge info", KR(ret), K_(tenant_id));
|
||||
} else if (OB_FAIL(ObZoneMergeTableOperator::get_zone_list(*proxy_, tenant_id_, zone_list))) {
|
||||
LOG_WARN("fail to get zone list", KR(ret), K_(tenant_id));
|
||||
@ -88,7 +90,8 @@ int ObZoneMergeManagerBase::reload()
|
||||
ObZoneMergeInfo &info = tmp_merge_infos.ptr()[i];
|
||||
info.zone_ = zone_list[i];
|
||||
info.tenant_id_ = tenant_id_;
|
||||
if (OB_FAIL(ObZoneMergeTableOperator::load_zone_merge_info(*proxy_, tenant_id_, info))) {
|
||||
if (OB_FAIL(ObZoneMergeTableOperator::load_zone_merge_info(*proxy_, tenant_id_, info,
|
||||
true/*print_sql*/))) {
|
||||
LOG_WARN("fail to reload zone merge info", KR(ret), K_(tenant_id), "zone", zone_list[i]);
|
||||
}
|
||||
}
|
||||
@ -110,7 +113,8 @@ int ObZoneMergeManagerBase::reload()
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
is_loaded_ = true;
|
||||
LOG_INFO("succ to reload zone merge manager", K(zone_list));
|
||||
LOG_INFO("succ to reload zone merge manager", K(zone_list), K_(global_merge_info),
|
||||
"zone_merge_infos", ObArrayWrap<ObZoneMergeInfo>(zone_merge_infos_, zone_count_));
|
||||
} else {
|
||||
LOG_WARN("fail to reload zone merge manager", KR(ret));
|
||||
}
|
||||
|
||||
@ -165,6 +165,7 @@ int ObFreezeInfoProxy::get_freeze_info_larger_or_equal_than(
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_INFO("finish load_freeze_info", KR(ret), K_(tenant_id), K(sql));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,8 @@ using namespace oceanbase::common::sqlclient;
|
||||
int ObGlobalMergeTableOperator::load_global_merge_info(
|
||||
ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
ObGlobalMergeInfo &info)
|
||||
ObGlobalMergeInfo &info,
|
||||
const bool print_sql)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (!is_valid_tenant_id(tenant_id)) {
|
||||
@ -85,6 +86,9 @@ int ObGlobalMergeTableOperator::load_global_merge_info(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (print_sql) {
|
||||
LOG_INFO("finish load_gloal_merge_info", KR(ret), K(tenant_id), K(sql));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -153,6 +157,14 @@ int ObGlobalMergeTableOperator::update_partial_global_merge_info(
|
||||
if (it->is_scn_) {
|
||||
if (OB_FAIL(dml.add_uint64_column(it->name_, it->get_scn_val()))) {
|
||||
LOG_WARN("fail to add scn column", KR(ret), K(tenant_id), K(info), K(*it));
|
||||
} else if (dml.get_extra_condition().empty()) {
|
||||
if (OB_FAIL(dml.get_extra_condition().assign_fmt("%s < %ld", it->name_, it->get_scn_val()))) {
|
||||
LOG_WARN("fail to assign extra_condition", KR(ret), K(tenant_id));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(dml.get_extra_condition().append_fmt(" AND %s < %ld", it->name_, it->get_scn_val()))) {
|
||||
LOG_WARN("fail to assign extra_condition", KR(ret), K(tenant_id));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(dml.add_uint64_column(it->name_, it->value_))) {
|
||||
@ -171,6 +183,10 @@ int ObGlobalMergeTableOperator::update_partial_global_merge_info(
|
||||
} else if (!(is_single_row(affected_rows) || is_zero_row(affected_rows))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("unexpected affected rows", KR(ret), K(affected_rows), K(meta_tenant_id));
|
||||
} else if (is_zero_row(affected_rows)) {
|
||||
if (OB_FAIL(check_scn_revert(sql_client, tenant_id, info))) {
|
||||
LOG_WARN("fail to check scn revert", KR(ret), K(tenant_id));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
@ -181,5 +197,53 @@ int ObGlobalMergeTableOperator::update_partial_global_merge_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObGlobalMergeTableOperator::check_scn_revert(
|
||||
ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const ObGlobalMergeInfo &info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id) || !info.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(info));
|
||||
} else {
|
||||
HEAP_VAR(ObGlobalMergeInfo, global_merge_info) {
|
||||
if (OB_FAIL(ObGlobalMergeTableOperator::load_global_merge_info(sql_client, tenant_id,
|
||||
global_merge_info))) {
|
||||
LOG_WARN("fail to load global merge info", KR(ret), K(tenant_id));
|
||||
} else {
|
||||
const ObMergeInfoItem *it = info.list_.get_first();
|
||||
while (OB_SUCC(ret) && (it != info.list_.get_header())) {
|
||||
if (NULL == it) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("null item", KR(ret), KP(it), K(tenant_id), K(info));
|
||||
} else {
|
||||
if (it->need_update_ && it->is_scn_) {
|
||||
if (0 == STRCMP(it->name_, "frozen_scn")) {
|
||||
if (it->get_scn() < global_merge_info.frozen_scn_.get_scn()) {
|
||||
LOG_ERROR("frozen_scn revert", K(tenant_id), "origin_frozen_scn", it->get_scn(),
|
||||
"new_frozen_scn", global_merge_info.frozen_scn_.get_scn());
|
||||
}
|
||||
} else if (0 == STRCMP(it->name_, "global_broadcast_scn")) {
|
||||
if (it->get_scn() < global_merge_info.global_broadcast_scn_.get_scn()) {
|
||||
LOG_ERROR("global_broadcast_scn revert", K(tenant_id), "origin_global_broadcast_scn",
|
||||
it->get_scn(), "new_global_broadcast_scn", global_merge_info.global_broadcast_scn_.get_scn());
|
||||
}
|
||||
} else if (0 == STRCMP(it->name_, "last_merged_scn")) {
|
||||
if (it->get_scn() < global_merge_info.last_merged_scn_.get_scn()) {
|
||||
LOG_ERROR("last_merged_scn revert", K(tenant_id), "origin_last_merged_scn",
|
||||
it->get_scn(), "new_last_merged_scn", global_merge_info.last_merged_scn_.get_scn());
|
||||
}
|
||||
}
|
||||
}
|
||||
it = it->get_next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
|
||||
@ -35,7 +35,8 @@ class ObGlobalMergeTableOperator
|
||||
public:
|
||||
static int load_global_merge_info(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
share::ObGlobalMergeInfo &info);
|
||||
share::ObGlobalMergeInfo &info,
|
||||
const bool print_sql = false);
|
||||
static int insert_global_merge_info(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const share::ObGlobalMergeInfo &info);
|
||||
@ -43,6 +44,11 @@ public:
|
||||
static int update_partial_global_merge_info(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const share::ObGlobalMergeInfo &info);
|
||||
|
||||
private:
|
||||
static int check_scn_revert(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const share::ObGlobalMergeInfo &info);
|
||||
};
|
||||
|
||||
} // end namespace share
|
||||
|
||||
@ -235,7 +235,8 @@ bool ObZoneMergeInfo::is_valid() const
|
||||
|| (!last_merged_scn_.is_valid())
|
||||
|| (last_merged_time_.get_value() < 0)
|
||||
|| (merge_start_time_.get_value() < 0)
|
||||
|| (!all_merged_scn_.is_valid())) {
|
||||
|| (!all_merged_scn_.is_valid())
|
||||
|| (!frozen_scn_.is_valid())) {
|
||||
is_valid = false;
|
||||
}
|
||||
return is_valid;
|
||||
|
||||
@ -32,13 +32,14 @@ using namespace oceanbase::common::sqlclient;
|
||||
int ObZoneMergeTableOperator::load_zone_merge_info(
|
||||
ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
ObZoneMergeInfo &info)
|
||||
ObZoneMergeInfo &info,
|
||||
const bool print_sql)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObArray<ObZoneMergeInfo> infos;
|
||||
if (OB_FAIL(infos.push_back(info))) {
|
||||
LOG_WARN("fail to push back zone merge info", KR(ret), K(info));
|
||||
} else if (OB_FAIL(load_zone_merge_infos(sql_client, tenant_id, infos))) {
|
||||
} else if (OB_FAIL(load_zone_merge_infos(sql_client, tenant_id, infos, print_sql))) {
|
||||
LOG_WARN("fail to load zone merge infos", KR(ret), K(info));
|
||||
} else if (OB_UNLIKELY(infos.count() != 1)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -52,9 +53,10 @@ int ObZoneMergeTableOperator::load_zone_merge_info(
|
||||
int ObZoneMergeTableOperator::load_zone_merge_infos(
|
||||
ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
ObIArray<ObZoneMergeInfo> &infos)
|
||||
ObIArray<ObZoneMergeInfo> &infos,
|
||||
const bool print_sql)
|
||||
{
|
||||
return inner_load_zone_merge_infos_(sql_client, tenant_id, infos);
|
||||
return inner_load_zone_merge_infos_(sql_client, tenant_id, infos, print_sql);
|
||||
}
|
||||
|
||||
int ObZoneMergeTableOperator::insert_zone_merge_info(
|
||||
@ -110,6 +112,14 @@ int ObZoneMergeTableOperator::update_partial_zone_merge_info(
|
||||
if (it->is_scn_) {
|
||||
if (OB_FAIL(dml.add_uint64_column(it->name_, it->get_scn_val()))) {
|
||||
LOG_WARN("fail to add scn column", KR(ret), K(tenant_id), K(info), K(*it));
|
||||
} else if (dml.get_extra_condition().empty()) {
|
||||
if (OB_FAIL(dml.get_extra_condition().assign_fmt("%s < %ld", it->name_, it->get_scn_val()))) {
|
||||
LOG_WARN("fail to assign extra_condition", KR(ret), K(tenant_id));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(dml.get_extra_condition().append_fmt(" AND %s < %ld", it->name_, it->get_scn_val()))) {
|
||||
LOG_WARN("fail to assign extra_condition", KR(ret), K(tenant_id));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(dml.add_uint64_column(it->name_, it->value_))) {
|
||||
@ -128,6 +138,10 @@ int ObZoneMergeTableOperator::update_partial_zone_merge_info(
|
||||
} else if (!(is_single_row(affected_rows) || is_zero_row(affected_rows))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("unexpected affected rows", KR(ret), K(affected_rows), K(meta_tenant_id), K(info));
|
||||
} else if (is_zero_row(affected_rows)) {
|
||||
if (OB_FAIL(check_scn_revert(sql_client, tenant_id, info))) {
|
||||
LOG_WARN("fail to check scn revert", KR(ret), K(tenant_id));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
@ -321,7 +335,8 @@ int ObZoneMergeTableOperator::get_zone_list(
|
||||
int ObZoneMergeTableOperator::inner_load_zone_merge_infos_(
|
||||
common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
ObIArray<ObZoneMergeInfo> &infos)
|
||||
ObIArray<ObZoneMergeInfo> &infos,
|
||||
const bool print_sql)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -377,6 +392,9 @@ int ObZoneMergeTableOperator::inner_load_zone_merge_infos_(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (print_sql) {
|
||||
LOG_INFO("finish load_zone_merge_info", KR(ret), K(tenant_id), K(sql));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -448,5 +466,60 @@ int ObZoneMergeTableOperator::construct_zone_merge_info_(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObZoneMergeTableOperator::check_scn_revert(
|
||||
common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const share::ObZoneMergeInfo &info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id) || !info.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(info));
|
||||
} else {
|
||||
HEAP_VAR(ObZoneMergeInfo, zone_merge_info) {
|
||||
zone_merge_info.tenant_id_ = tenant_id;
|
||||
zone_merge_info.zone_ = info.zone_;
|
||||
if (OB_FAIL(ObZoneMergeTableOperator::load_zone_merge_info(sql_client, tenant_id,
|
||||
zone_merge_info))) {
|
||||
LOG_WARN("fail to load zone merge info", KR(ret), K(tenant_id));
|
||||
} else {
|
||||
const ObMergeInfoItem *it = info.list_.get_first();
|
||||
while (OB_SUCC(ret) && (it != info.list_.get_header())) {
|
||||
if (NULL == it) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("null item", KR(ret), KP(it), K(tenant_id), K(info));
|
||||
} else {
|
||||
if (it->need_update_ && it->is_scn_) {
|
||||
if (0 == STRCMP(it->name_, "frozen_scn")) {
|
||||
if (it->get_scn() < zone_merge_info.frozen_scn_.get_scn()) {
|
||||
LOG_ERROR("frozen_scn revert", K(tenant_id), "origin_frozen_scn", it->get_scn(),
|
||||
"new_frozen_scn", zone_merge_info.frozen_scn_.get_scn());
|
||||
}
|
||||
} else if (0 == STRCMP(it->name_, "broadcast_scn")) {
|
||||
if (it->get_scn() < zone_merge_info.broadcast_scn_.get_scn()) {
|
||||
LOG_ERROR("broadcast_scn revert", K(tenant_id), "origin_broadcast_scn",
|
||||
it->get_scn(), "new_broadcast_scn", zone_merge_info.broadcast_scn_.get_scn());
|
||||
}
|
||||
} else if (0 == STRCMP(it->name_, "last_merged_scn")) {
|
||||
if (it->get_scn() < zone_merge_info.last_merged_scn_.get_scn()) {
|
||||
LOG_ERROR("last_merged_scn revert", K(tenant_id), "origin_last_merged_scn",
|
||||
it->get_scn(), "new_last_merged_scn", zone_merge_info.last_merged_scn_.get_scn());
|
||||
}
|
||||
} else if (0 == STRCMP(it->name_, "all_merged_scn")) {
|
||||
if (it->get_scn() < zone_merge_info.all_merged_scn_.get_scn()) {
|
||||
LOG_ERROR("all_merged_scn revert", K(tenant_id), "origin_all_merged_scn",
|
||||
it->get_scn(), "new_all_merged_scn", zone_merge_info.all_merged_scn_.get_scn());
|
||||
}
|
||||
}
|
||||
}
|
||||
it = it->get_next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end namespace share
|
||||
} // end namespace oceanbase
|
||||
|
||||
@ -36,10 +36,12 @@ public:
|
||||
common::ObIArray<common::ObZone> &zone_list);
|
||||
static int load_zone_merge_info(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
share::ObZoneMergeInfo &info);
|
||||
share::ObZoneMergeInfo &info,
|
||||
const bool print_sql = false);
|
||||
static int load_zone_merge_infos(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
common::ObIArray<share::ObZoneMergeInfo> &infos);
|
||||
common::ObIArray<share::ObZoneMergeInfo> &infos,
|
||||
const bool print_sql = false);
|
||||
|
||||
static int insert_zone_merge_info(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
@ -68,7 +70,8 @@ public:
|
||||
private:
|
||||
static int inner_load_zone_merge_infos_(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
common::ObIArray<share::ObZoneMergeInfo> &infos);
|
||||
common::ObIArray<share::ObZoneMergeInfo> &infos,
|
||||
const bool print_sql = false);
|
||||
static int inner_insert_or_update_zone_merge_infos_(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const bool is_update,
|
||||
@ -76,6 +79,10 @@ private:
|
||||
static int construct_zone_merge_info_(common::sqlclient::ObMySQLResult &result,
|
||||
const bool need_check,
|
||||
common::ObIArray<share::ObZoneMergeInfo> &infos);
|
||||
|
||||
static int check_scn_revert(common::ObISQLClient &sql_client,
|
||||
const uint64_t tenant_id,
|
||||
const share::ObZoneMergeInfo &info);
|
||||
};
|
||||
|
||||
} // end namespace share
|
||||
|
||||
Reference in New Issue
Block a user