fix major freeze about updating report_scn in case of backup-restore tenant
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "share/ob_dml_sql_splicer.h"
|
||||
#include "share/tablet/ob_tablet_filter.h"
|
||||
#include "share/ob_service_epoch_proxy.h"
|
||||
#include "share/scn.h"
|
||||
#include "observer/ob_server_struct.h"
|
||||
|
||||
namespace oceanbase
|
||||
@ -243,6 +244,56 @@ int ObTabletMetaTableCompactionOperator::batch_update_unequal_report_scn_tablet(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMetaTableCompactionOperator::get_min_compaction_scn(
|
||||
const uint64_t tenant_id,
|
||||
SCN &min_compaction_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t start_time_us = ObTimeUtil::current_time();
|
||||
if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), K(tenant_id));
|
||||
} else {
|
||||
const uint64_t meta_tenant_id = gen_meta_tenant_id(tenant_id);
|
||||
int64_t estimated_timeout_us = 0;
|
||||
ObTimeoutCtx timeout_ctx;
|
||||
// set trx_timeout and query_timeout based on tablet_replica_cnt
|
||||
if (OB_FAIL(ObTabletMetaTableCompactionOperator::get_estimated_timeout_us(tenant_id,
|
||||
estimated_timeout_us))) {
|
||||
LOG_WARN("fail to get estimated_timeout_us", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(timeout_ctx.set_trx_timeout_us(estimated_timeout_us))) {
|
||||
LOG_WARN("fail to set trx timeout", KR(ret), K(estimated_timeout_us));
|
||||
} else if (OB_FAIL(timeout_ctx.set_timeout(estimated_timeout_us))) {
|
||||
LOG_WARN("fail to set abs timeout", KR(ret), K(estimated_timeout_us));
|
||||
} else {
|
||||
ObSqlString sql;
|
||||
SMART_VAR(ObISQLClient::ReadResult, res) {
|
||||
ObMySQLResult *result = nullptr;
|
||||
if (OB_FAIL(sql.assign_fmt("SELECT MIN(compaction_scn) as value FROM %s WHERE tenant_id ="
|
||||
" '%ld' ", OB_ALL_TABLET_META_TABLE_TNAME, tenant_id))) {
|
||||
LOG_WARN("failed to append fmt", K(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(GCTX.sql_proxy_->read(res, meta_tenant_id, sql.ptr()))) {
|
||||
LOG_WARN("fail to execute sql", KR(ret), K(tenant_id), K(meta_tenant_id), K(sql));
|
||||
} else if (OB_ISNULL(result = res.get_result())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to get mysql result", KR(ret), K(tenant_id), K(sql));
|
||||
} else if (OB_FAIL(result->next())) {
|
||||
LOG_WARN("get next result failed", KR(ret), K(tenant_id), K(sql));
|
||||
} else {
|
||||
uint64_t min_compaction_scn_val = UINT64_MAX;
|
||||
EXTRACT_UINT_FIELD_MYSQL(*result, "value", min_compaction_scn_val, uint64_t);
|
||||
if (FAILEDx(min_compaction_scn.convert_for_inner_table_field(min_compaction_scn_val))) {
|
||||
LOG_WARN("fail to convert uint64_t to SCN", KR(ret), K(min_compaction_scn_val));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_INFO("finish to get min_compaction_scn", KR(ret), K(tenant_id), K(min_compaction_scn),
|
||||
"cost_time_us", ObTimeUtil::current_time() - start_time_us, K(estimated_timeout_us));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMetaTableCompactionOperator::construct_unequal_tablet_id_array(
|
||||
sqlclient::ObMySQLResult &result,
|
||||
common::ObIArray<ObTabletID> &unequal_tablet_id_array)
|
||||
|
||||
Reference in New Issue
Block a user