[CP] [UPGRADE] Record more info in DBA_OB_TENANT_JOBS/DBA_OB_CLUSTER_EVENT_HISTORY
This commit is contained in:
@ -2001,13 +2001,17 @@ int ObRootService::execute_bootstrap(const obrpc::ObBootstrapArg &arg)
|
||||
if (OB_SUCC(ret)) {
|
||||
char ori_min_server_version[OB_SERVER_VERSION_LENGTH] = {'\0'};
|
||||
uint64_t ori_cluster_version = GET_MIN_CLUSTER_VERSION();
|
||||
share::ObServerInfoInTable::ObBuildVersion build_version;
|
||||
if (OB_INVALID_INDEX == ObClusterVersion::print_version_str(
|
||||
ori_min_server_version, OB_SERVER_VERSION_LENGTH, ori_cluster_version)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("fail to print version str", KR(ret), K(ori_cluster_version));
|
||||
} else if (OB_FAIL(observer::ObService::get_build_version(build_version))) {
|
||||
LOG_WARN("fail to get build version", KR(ret));
|
||||
} else {
|
||||
CLUSTER_EVENT_SYNC_ADD("BOOTSTRAP", "BOOTSTRAP_SUCCESS",
|
||||
"cluster_version", ori_min_server_version);
|
||||
"cluster_version", ori_min_server_version,
|
||||
"build_version", build_version.ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
#include "logservice/leader_coordinator/table_accessor.h"
|
||||
#include "rootserver/freeze/ob_major_freeze_helper.h"
|
||||
#include "share/ob_cluster_event_history_table_operator.h"//CLUSTER_EVENT_INSTANCE
|
||||
#include "observer/ob_service.h"
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace common;
|
||||
@ -1528,12 +1529,16 @@ int ObAdminUpgradeCmd::execute(const Bool &upgrade)
|
||||
LOG_WARN("add _upgrade_stage config item failed", KR(ret), K(stage), K(upgrade));
|
||||
}
|
||||
}
|
||||
share::ObServerInfoInTable::ObBuildVersion build_version;
|
||||
if (FAILEDx(admin_set_config.execute(set_config_arg))) {
|
||||
LOG_WARN("execute set config failed", KR(ret));
|
||||
} else if (OB_FAIL(observer::ObService::get_build_version(build_version))) {
|
||||
LOG_WARN("fail to get build version", KR(ret));
|
||||
} else {
|
||||
CLUSTER_EVENT_SYNC_ADD("UPGRADE",
|
||||
upgrade ? "BEGIN_UPGRADE" : "END_UPGRADE",
|
||||
"cluster_version", min_server_version);
|
||||
"cluster_version", min_server_version,
|
||||
"build_version", build_version.ptr());
|
||||
LOG_INFO("change upgrade parameters",
|
||||
"enable_upgrade_mode", upgrade,
|
||||
"in_major_version_upgrade_mode", GCONF.in_major_version_upgrade_mode());
|
||||
@ -1586,13 +1591,18 @@ int ObAdminRollingUpgradeCmd::execute(const obrpc::ObAdminRollingUpgradeArg &arg
|
||||
if (FAILEDx(admin_set_config.execute(set_config_arg))) {
|
||||
LOG_WARN("execute set config failed", KR(ret));
|
||||
} else {
|
||||
if (obrpc::OB_UPGRADE_STAGE_POSTUPGRADE != arg.stage_) {
|
||||
share::ObServerInfoInTable::ObBuildVersion build_version;
|
||||
if (OB_FAIL(observer::ObService::get_build_version(build_version))) {
|
||||
LOG_WARN("fail to get build version", KR(ret));
|
||||
} else if (obrpc::OB_UPGRADE_STAGE_POSTUPGRADE != arg.stage_) {
|
||||
CLUSTER_EVENT_SYNC_ADD("UPGRADE", "BEGIN_ROLLING_UPGRADE",
|
||||
"cluster_version", ori_min_server_version);
|
||||
"cluster_version", ori_min_server_version,
|
||||
"build_version", build_version.ptr());
|
||||
} else {
|
||||
CLUSTER_EVENT_SYNC_ADD("UPGRADE", "END_ROLLING_UPGRADE",
|
||||
"cluster_version", min_server_version,
|
||||
"ori_cluster_version", ori_min_server_version);
|
||||
"ori_cluster_version", ori_min_server_version,
|
||||
"build_version", build_version.ptr());
|
||||
}
|
||||
LOG_INFO("change upgrade parameters", KR(ret), "_upgrade_stage", arg.stage_);
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "share/ob_cluster_event_history_table_operator.h"//CLUSTER_EVENT_INSTANCE
|
||||
#include "share/ob_primary_standby_service.h" // ObPrimaryStandbyService
|
||||
#include "share/ob_tenant_info_proxy.h" //ObAllTenantInfoProxy
|
||||
#include "observer/ob_service.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -306,25 +307,27 @@ int ObUpgradeExecutor::execute(
|
||||
LOG_WARN("unsupported version to run upgrade job", KR(ret), K(arg));
|
||||
} else if (OB_FAIL(set_execute_mark_())) {
|
||||
LOG_WARN("fail to set execute mark", KR(ret));
|
||||
} else if (OB_FAIL(construct_tenant_ids_(arg.tenant_ids_, tenant_ids))) {
|
||||
LOG_WARN("fail to construct tenant_ids", KR(ret), K(arg));
|
||||
} else {
|
||||
const uint64_t tenant_id = (1 == tenant_ids.count()) ? tenant_ids.at(0) : 0;
|
||||
const int64_t BUF_LEN = common::MAX_ROOTSERVICE_EVENT_EXTRA_INFO_LENGTH;
|
||||
char extra_buf[BUF_LEN] = {'\0'};
|
||||
int64_t job_id = OB_INVALID_ID;
|
||||
ObString extra_info;
|
||||
char extra_buf[common::MAX_ROOTSERVICE_EVENT_EXTRA_INFO_LENGTH] = {0};
|
||||
int64_t len = 0;
|
||||
if (version > 0) {
|
||||
len = ObClusterVersion::print_version_str(
|
||||
extra_buf, common::OB_CLUSTER_VERSION_LENGTH, version);
|
||||
}
|
||||
extra_info.assign_ptr(extra_buf, len);
|
||||
if (OB_FAIL(RS_JOB_CREATE_WITH_RET(job_id, job_type, *sql_proxy_,
|
||||
"tenant_id", 0,
|
||||
"extra_info", extra_buf))) {
|
||||
uint64_t current_data_version = 0;
|
||||
if (0 != tenant_id && OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, current_data_version))) {
|
||||
LOG_WARN("fail to get min data version", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(fill_extra_info_(tenant_id, version,
|
||||
current_data_version, BUF_LEN, extra_buf))) {
|
||||
LOG_WARN("fail to fill extra info", KR(ret),
|
||||
K(tenant_id), K(version), K(current_data_version));
|
||||
} else if (OB_FAIL(RS_JOB_CREATE_WITH_RET(
|
||||
job_id, job_type, *sql_proxy_, "tenant_id", tenant_id,
|
||||
"extra_info", ObHexEscapeSqlStr(ObString(strlen(extra_buf), extra_buf))))) {
|
||||
LOG_WARN("fail to create rs job", KR(ret));
|
||||
} else if (job_id <= 0) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("job_id is invalid", KR(ret), K(job_id));
|
||||
} else if (OB_FAIL(construct_tenant_ids_(arg.tenant_ids_, tenant_ids))) {
|
||||
LOG_WARN("fail to construct tenant_ids", KR(ret), K(arg));
|
||||
} else {
|
||||
switch (action) {
|
||||
case obrpc::ObUpgradeJobArg::UPGRADE_POST_ACTION: {
|
||||
@ -396,16 +399,42 @@ int ObUpgradeExecutor::execute(
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
char ori_min_server_version[OB_SERVER_VERSION_LENGTH] = {'\0'};
|
||||
uint64_t ori_cluster_version = GET_MIN_CLUSTER_VERSION();
|
||||
const int64_t BUF_LEN = OB_SERVER_VERSION_LENGTH;
|
||||
char min_cluster_version_str[BUF_LEN] = {'\0'};
|
||||
const uint64_t min_cluster_version = GET_MIN_CLUSTER_VERSION();
|
||||
char targe_data_version_str[BUF_LEN] = {'\0'};
|
||||
const uint64_t target_data_version = DATA_CURRENT_VERSION;
|
||||
share::ObServerInfoInTable::ObBuildVersion build_version;
|
||||
if (OB_INVALID_INDEX == ObClusterVersion::print_version_str(
|
||||
ori_min_server_version, OB_SERVER_VERSION_LENGTH, ori_cluster_version)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("fail to print version str", KR(ret), K(ori_cluster_version));
|
||||
min_cluster_version_str, BUF_LEN, min_cluster_version)) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("fail to print version str", KR(ret), K(min_cluster_version));
|
||||
} else if (OB_INVALID_INDEX == ObClusterVersion::print_version_str(
|
||||
targe_data_version_str, BUF_LEN, target_data_version)) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("fail to print version str", KR(ret), K(target_data_version));
|
||||
} else if (OB_FAIL(observer::ObService::get_build_version(build_version))) {
|
||||
LOG_WARN("fail to get build version", KR(ret));
|
||||
} else if (0 != tenant_id) {
|
||||
char current_data_version_str[BUF_LEN] = {'\0'};
|
||||
if (OB_INVALID_INDEX == ObClusterVersion::print_version_str(
|
||||
current_data_version_str, BUF_LEN, current_data_version)) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("fail to print version str", KR(ret), K(current_data_version));
|
||||
}
|
||||
CLUSTER_EVENT_SYNC_ADD("UPGRADE",
|
||||
ObRsJobTableOperator::get_job_type_str(job_type),
|
||||
"cluster_version", min_cluster_version_str,
|
||||
"build_version", build_version.ptr(),
|
||||
"target_data_version", targe_data_version_str,
|
||||
"current_data_version", current_data_version_str,
|
||||
"tenant_id", tenant_id)
|
||||
} else {
|
||||
CLUSTER_EVENT_SYNC_ADD("UPGRADE",
|
||||
ObRsJobTableOperator::get_job_type_str(job_type),
|
||||
"cluster_version", ori_min_server_version);
|
||||
"cluster_version", min_cluster_version_str,
|
||||
"build_version", build_version.ptr(),
|
||||
"target_data_version", targe_data_version_str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,6 +450,58 @@ int ObUpgradeExecutor::execute(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObUpgradeExecutor::fill_extra_info_(
|
||||
const uint64_t tenant_id,
|
||||
const int64_t specified_version,
|
||||
const uint64_t current_data_version,
|
||||
const int64_t buf_len,
|
||||
char *buf)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t len = 0;
|
||||
const int64_t VERSION_LEN = common::OB_CLUSTER_VERSION_LENGTH;
|
||||
char version_buf[VERSION_LEN] = {'\0'};
|
||||
int64_t version_len = 0;
|
||||
if (specified_version > 0) {
|
||||
if (OB_INVALID_INDEX == (version_len = ObClusterVersion::print_version_str(
|
||||
version_buf, VERSION_LEN, static_cast<uint64_t>(specified_version)))) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("fail to print version", KR(ret), K(specified_version));
|
||||
} else if (OB_FAIL(databuff_printf(buf, buf_len, len,
|
||||
"SPECIFIED_DATA_VERSION: '%s'", version_buf))) {
|
||||
LOG_WARN("fail to print string", KR(ret), K(len));
|
||||
}
|
||||
} else {
|
||||
if (OB_SUCC(ret)) {
|
||||
uint64_t target_data_version = DATA_CURRENT_VERSION;
|
||||
if (OB_INVALID_INDEX == (version_len = ObClusterVersion::print_version_str(
|
||||
version_buf, VERSION_LEN, target_data_version))) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("fail to print version", KR(ret), K(target_data_version));
|
||||
} else if (OB_FAIL(databuff_printf(buf, buf_len, len,
|
||||
"TARGET_DATA_VERSION: '%s'", version_buf))) {
|
||||
LOG_WARN("fail to print string", KR(ret), K(len));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (0 != tenant_id) {
|
||||
// record current data version when upgrade single tenant
|
||||
if (OB_UNLIKELY(len < 1)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("str should not be empty", KR(ret), K(len));
|
||||
} else if (OB_INVALID_INDEX == (version_len = ObClusterVersion::print_version_str(
|
||||
version_buf, VERSION_LEN, current_data_version))) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("fail to print version", KR(ret), K(current_data_version));
|
||||
} else if (OB_FAIL(databuff_printf(buf, buf_len, len,
|
||||
", CURRENT_DATA_VERSION: '%s'", version_buf))) {
|
||||
LOG_WARN("fail to print string", KR(ret), K(len));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Python upgrade script may set enable_ddl = false before it run upgrade job.
|
||||
// this function won't raise current_data_version
|
||||
int ObUpgradeExecutor::run_upgrade_post_job_(
|
||||
|
||||
@ -105,6 +105,13 @@ private:
|
||||
common::ObIArray<uint64_t> &dst_tenant_ids);
|
||||
rootserver::ObRsJobType convert_to_job_type_(
|
||||
const obrpc::ObUpgradeJobArg::Action &action);
|
||||
|
||||
int fill_extra_info_(
|
||||
const uint64_t tenant_id,
|
||||
const int64_t specified_version,
|
||||
const uint64_t current_data_version,
|
||||
const int64_t buf_len,
|
||||
char *buf);
|
||||
private:
|
||||
bool inited_;
|
||||
bool stopped_;
|
||||
|
||||
@ -760,7 +760,7 @@ int ObInnerTableSchema::dba_ob_tenant_jobs_schema(ObTableSchema &table_schema)
|
||||
table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT JOB_ID, JOB_TYPE, JOB_STATUS, RESULT_CODE, PROGRESS, gmt_create AS START_TIME, gmt_modified AS MODIFY_TIME, TENANT_ID, SQL_TEXT, EXTRA_INFO, RS_SVR_IP, RS_SVR_PORT FROM oceanbase.__all_rootservice_job WHERE JOB_TYPE in ( 'ALTER_TENANT_LOCALITY', 'ROLLBACK_ALTER_TENANT_LOCALITY', 'SHRINK_RESOURCE_TENANT_UNIT_NUM', 'ALTER_TENANT_PRIMARY_ZONE', 'ALTER_RESOURCE_TENANT_UNIT_NUM' ) )__"))) {
|
||||
if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT JOB_ID, JOB_TYPE, JOB_STATUS, RESULT_CODE, PROGRESS, gmt_create AS START_TIME, gmt_modified AS MODIFY_TIME, TENANT_ID, SQL_TEXT, EXTRA_INFO, RS_SVR_IP, RS_SVR_PORT FROM oceanbase.__all_rootservice_job WHERE JOB_TYPE in ( 'ALTER_TENANT_LOCALITY', 'ROLLBACK_ALTER_TENANT_LOCALITY', 'SHRINK_RESOURCE_TENANT_UNIT_NUM', 'ALTER_TENANT_PRIMARY_ZONE', 'ALTER_RESOURCE_TENANT_UNIT_NUM', 'UPGRADE_POST_ACTION', 'UPGRADE_SYSTEM_VARIABLE', 'UPGRADE_SYSTEM_TABLE', 'UPGRADE_BEGIN', 'UPGRADE_VIRTUAL_SCHEMA', 'UPGRADE_SYSTEM_PACKAGE', 'UPGRADE_ALL_POST_ACTION', 'UPGRADE_INSPECTION', 'UPGRADE_END', 'UPGRADE_ALL' ) AND TENANT_ID != 0 )__"))) {
|
||||
LOG_ERROR("fail to set view_definition", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
@ -17494,8 +17494,19 @@ WHERE
|
||||
'ROLLBACK_ALTER_TENANT_LOCALITY',
|
||||
'SHRINK_RESOURCE_TENANT_UNIT_NUM',
|
||||
'ALTER_TENANT_PRIMARY_ZONE',
|
||||
'ALTER_RESOURCE_TENANT_UNIT_NUM'
|
||||
'ALTER_RESOURCE_TENANT_UNIT_NUM',
|
||||
'UPGRADE_POST_ACTION',
|
||||
'UPGRADE_SYSTEM_VARIABLE',
|
||||
'UPGRADE_SYSTEM_TABLE',
|
||||
'UPGRADE_BEGIN',
|
||||
'UPGRADE_VIRTUAL_SCHEMA',
|
||||
'UPGRADE_SYSTEM_PACKAGE',
|
||||
'UPGRADE_ALL_POST_ACTION',
|
||||
'UPGRADE_INSPECTION',
|
||||
'UPGRADE_END',
|
||||
'UPGRADE_ALL'
|
||||
)
|
||||
AND TENANT_ID != 0
|
||||
""".replace("\n", " ")
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user