add log of load freeze_info/global_merge_info/zone_merge_info and defence of scn_revert
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user