Do not report ERROR when sample rate equals 100

This commit is contained in:
ZenoWang
2024-02-06 14:49:31 +00:00
committed by ob-robot
parent 1f1d5c08ae
commit c8ef409bf3
3710 changed files with 486984 additions and 3083329 deletions

View File

@ -22,6 +22,7 @@
#endif
#include "lib/mysqlclient/ob_isql_client.h"
#include "observer/omt/ob_tenant_config_mgr.h" // ObTenantConfigGuard
#include "storage/ls/ob_ls.h" //ObLS
namespace oceanbase
{
@ -310,8 +311,8 @@ int ObShareUtil::fetch_current_data_version(
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant_id is invalid", KR(ret), K(tenant_id), K(exec_tenant_id));
} else if (OB_FAIL(sql.assign_fmt(
"select value from %s where name = '%s' and tenant_id = %lu",
OB_TENANT_PARAMETER_TNAME, "compatible", tenant_id))) {
"select value from %s where name = '%s'",
OB_TENANT_PARAMETER_TNAME, "compatible"))) {
LOG_WARN("fail to assign fmt", KR(ret), K(tenant_id), K(sql));
} else if (OB_FAIL(client.read(res, exec_tenant_id, sql.ptr()))) {
LOG_WARN("execute sql failed", KR(ret), K(tenant_id), K(sql));
@ -446,32 +447,58 @@ bool ObShareUtil::is_tenant_enable_transfer(const uint64_t tenant_id)
return bret;
}
int ObShareUtil::check_compat_version_for_clone_tenant(
const uint64_t tenant_id,
bool &is_compatible)
ERRSIM_POINT_DEF(ERRSIM_USER_LS_SYNC_SCN);
int ObShareUtil::wait_user_ls_sync_scn_locally(const share::SCN &sys_ls_target_scn, storage::ObLS &ls)
{
int ret = OB_SUCCESS;
is_compatible = false;
uint64_t data_version = 0;
if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id)) {
logservice::ObLogHandler *log_handler = ls.get_log_handler();
transaction::ObKeepAliveLSHandler *keep_alive_handler = ls.get_keep_alive_ls_handler();
ObLSID ls_id = ls.get_ls_id();
uint64_t tenant_id = ls.get_tenant_id();
ObTimeoutCtx ctx;
if (OB_ISNULL(keep_alive_handler) || OB_ISNULL(log_handler )) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("keep_alive_ls_handler or log_handler is null", KR(ret), K(ls_id),
KP(keep_alive_handler), KP(log_handler));
} else if (OB_UNLIKELY(!sys_ls_target_scn.is_valid_and_not_min())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", KR(ret), K(tenant_id));
} else if (OB_FAIL(GET_MIN_DATA_VERSION(OB_SYS_TENANT_ID, data_version))) {
LOG_WARN("fail to get sys tenant data version", KR(ret));
} else if (DATA_VERSION_4_3_0_0 > data_version) {
is_compatible = false;
} else if (is_sys_tenant(tenant_id)) {
is_compatible = true;
} else if (OB_FAIL(GET_MIN_DATA_VERSION(gen_user_tenant_id(tenant_id), data_version))) {
LOG_WARN("fail to get user tenant data version", KR(ret), "tenant_id", gen_user_tenant_id(tenant_id));
} else if (DATA_VERSION_4_3_0_0 > data_version) {
is_compatible = false;
} else if (OB_FAIL(GET_MIN_DATA_VERSION(gen_meta_tenant_id(tenant_id), data_version))) {
LOG_WARN("fail to get meta tenant data version", KR(ret), "tenant_id", gen_meta_tenant_id(tenant_id));
} else if (DATA_VERSION_4_3_0_0 > data_version) {
is_compatible = false;
LOG_WARN("invalid sys_ls_target_scn", KR(ret), K(sys_ls_target_scn));
} else if (OB_FAIL(ObShareUtil::set_default_timeout_ctx(ctx, GCONF.rpc_timeout))) {
LOG_WARN("fail to set timeout", KR(ret));
} else {
is_compatible = true;
bool need_retry = true;
share::SCN curr_end_scn;
curr_end_scn.set_min();
(void) keep_alive_handler->set_sys_ls_end_scn(sys_ls_target_scn);
do {
if (OB_UNLIKELY(ctx.is_timeouted())) {
ret = OB_TIMEOUT;
need_retry = false;
LOG_WARN("ctx timeout", KR(ret), K(ctx));
} else {
if (OB_FAIL(log_handler->get_end_scn(curr_end_scn))) {
LOG_WARN("fail to get ls end scn", KR(ret), K(ls_id));
} else {
// switchover to standby timeout
curr_end_scn = ERRSIM_USER_LS_SYNC_SCN ? SCN::scn_dec(sys_ls_target_scn) : curr_end_scn;
LOG_TRACE("wait curr_end_scn >= sys_ls_target_scn", K(curr_end_scn), K(sys_ls_target_scn),
"is_errsim_opened", ERRSIM_USER_LS_SYNC_SCN ? true : false);
}
if (OB_SUCC(ret) && curr_end_scn >= sys_ls_target_scn) {
LOG_INFO("current user ls end scn >= sys ls target scn now", K(curr_end_scn),
K(sys_ls_target_scn), "is_errsim_opened", ERRSIM_USER_LS_SYNC_SCN ? true : false,
K(tenant_id), K(ls_id));
need_retry = false;
}
}
if (need_retry) {
ob_usleep(50 * 1000); // wait 50ms
}
} while (need_retry && OB_SUCC(ret));
if (OB_UNLIKELY(need_retry && OB_SUCC(ret))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("the wait loop should not be terminated", KR(ret), K(curr_end_scn), K(sys_ls_target_scn));
}
}
return ret;
}