[FEAT MERGE] 开源裁减颗粒度优化
Co-authored-by: nroskill <nroskill@gmail.com> Co-authored-by: akaError <lzg020616@163.com> Co-authored-by: yinyj17 <yinyijun92@gmail.com>
This commit is contained in:
@ -31,6 +31,12 @@
|
||||
#include "share/rc/ob_context.h"
|
||||
#include "observer/ob_server_struct.h"
|
||||
#include "observer/mysql/ob_mysql_request_manager.h"
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
#include "share/arbitration_service/ob_arbitration_service_utils.h" //ObArbitrationServiceUtils
|
||||
#endif
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
#include "share/ob_master_key_getter.h"
|
||||
#endif
|
||||
#include "share/rc/ob_tenant_base.h"
|
||||
#include "share/scheduler/ob_dag_warning_history_mgr.h"
|
||||
#include "observer/omt/ob_tenant.h" //ObTenant
|
||||
@ -605,6 +611,13 @@ int ObAdminServerExecutor::execute(ObExecContext &ctx, ObAdminServerStmt &stmt)
|
||||
// check whether all leaders are switched out
|
||||
if (OB_FAIL(wait_leader_switch_out_(*(ctx.get_sql_proxy()), arg.servers_))) {
|
||||
LOG_WARN("fail to wait leader switch out", KR(ret), K(arg));
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
// check whether all 2f tenant with arb service finished degration
|
||||
} else if (OB_FAIL(ObArbitrationServiceUtils::wait_all_2f_tenants_arb_service_degration(
|
||||
*(ctx.get_sql_proxy()),
|
||||
arg.servers_))) {
|
||||
LOG_WARN("fail to wait degration for arb service", KR(ret), K(arg));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -768,6 +781,13 @@ int ObAdminZoneExecutor::execute(ObExecContext &ctx, ObAdminZoneStmt &stmt)
|
||||
} else if (OB_FAIL(wait_leader_switch_out_(*(ctx.get_sql_proxy()), arg))) {
|
||||
// check whether all leaders are switched out
|
||||
LOG_WARN("fail to wait leader switch out", KR(ret), K(arg));
|
||||
#ifdef OB_BUILD_ARBITRATION
|
||||
// check whether all 2f tenant with arb service finished degration
|
||||
} else if (OB_FAIL(ObArbitrationServiceUtils::wait_all_2f_tenants_arb_service_degration(
|
||||
*(ctx.get_sql_proxy()),
|
||||
server_list))) {
|
||||
LOG_WARN("fail to wait degration for arb service", KR(ret), K(arg), K(server_list));
|
||||
#endif
|
||||
}
|
||||
} else {} // force stop, no need to wait leader switch
|
||||
} else if (ObAdminZoneArg::MODIFY == stmt.get_op()) {
|
||||
@ -1154,30 +1174,115 @@ int ObMigrateUnitExecutor::execute(ObExecContext &ctx, ObMigrateUnitStmt &stmt)
|
||||
int ObAddArbitrationServiceExecutor::execute(ObExecContext &ctx, ObAddArbitrationServiceStmt &stmt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
#ifndef OB_BUILD_ARBITRATION
|
||||
UNUSEDx(ctx, stmt);
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not support in CE Version", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "add arbitration service in CE version");
|
||||
#else
|
||||
ObTaskExecutorCtx *task_exec_ctx = GET_TASK_EXECUTOR_CTX(ctx);
|
||||
obrpc::ObCommonRpcProxy *common_rpc = NULL;
|
||||
bool is_compatible = false;
|
||||
if (OB_ISNULL(task_exec_ctx)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("get task executor context failed", KR(ret));
|
||||
} else if (OB_FAIL(ObShareUtil::check_compat_version_for_arbitration_service(
|
||||
OB_SYS_TENANT_ID, is_compatible))) {
|
||||
LOG_WARN("fail to check compat version with arbitration service", KR(ret));
|
||||
} else if (!is_compatible) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("add arbitration service with data version below 4.1 not supported", KR(ret));
|
||||
} else if (OB_ISNULL(common_rpc = task_exec_ctx->get_common_rpc())) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("get common rpc proxy failed", KR(ret), K(task_exec_ctx));
|
||||
} else if (OB_FAIL(common_rpc->admin_add_arbitration_service(stmt.get_rpc_arg()))) {
|
||||
LOG_WARN("add arbitration service rpc failed", KR(ret), "rpc_arg", stmt.get_rpc_arg());
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObRemoveArbitrationServiceExecutor::execute(ObExecContext &ctx, ObRemoveArbitrationServiceStmt &stmt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
#ifndef OB_BUILD_ARBITRATION
|
||||
UNUSEDx(ctx, stmt);
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not support in CE Version", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "remove arbitration service in CE version");
|
||||
#else
|
||||
ObTaskExecutorCtx *task_exec_ctx = GET_TASK_EXECUTOR_CTX(ctx);
|
||||
obrpc::ObCommonRpcProxy *common_rpc = NULL;
|
||||
bool is_compatible = false;
|
||||
if (OB_ISNULL(task_exec_ctx)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("get task executor context failed", KR(ret));
|
||||
} else if (OB_FAIL(ObShareUtil::check_compat_version_for_arbitration_service(
|
||||
OB_SYS_TENANT_ID, is_compatible))) {
|
||||
LOG_WARN("fail to check compat version with arbitration service", KR(ret));
|
||||
} else if (!is_compatible) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("remove arbitration service with data version below 4.1 not supported", KR(ret));
|
||||
} else if (OB_ISNULL(common_rpc = task_exec_ctx->get_common_rpc())) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("get common rpc proxy failed", KR(ret), K(task_exec_ctx));
|
||||
} else if (OB_FAIL(common_rpc->admin_remove_arbitration_service(stmt.get_rpc_arg()))) {
|
||||
LOG_WARN("remove arbitration service rpc failed", KR(ret), "rpc_arg", stmt.get_rpc_arg());
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObReplaceArbitrationServiceExecutor::execute(ObExecContext &ctx, ObReplaceArbitrationServiceStmt &stmt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
#ifndef OB_BUILD_ARBITRATION
|
||||
UNUSEDx(ctx, stmt);
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not support in CE Version", KR(ret));
|
||||
LOG_USER_ERROR(OB_NOT_SUPPORTED, "replace arbitration service in CE version");
|
||||
#else
|
||||
ObTaskExecutorCtx *task_exec_ctx = GET_TASK_EXECUTOR_CTX(ctx);
|
||||
obrpc::ObCommonRpcProxy *common_rpc = NULL;
|
||||
bool is_compatible = false;
|
||||
if (OB_ISNULL(task_exec_ctx)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("get task executor context failed", KR(ret));
|
||||
} else if (OB_FAIL(ObShareUtil::check_compat_version_for_arbitration_service(
|
||||
OB_SYS_TENANT_ID, is_compatible))) {
|
||||
LOG_WARN("fail to check compat version with arbitration service", KR(ret));
|
||||
} else if (!is_compatible) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("replace arbitration service with data version below 4.1 not supported", KR(ret));
|
||||
} else if (OB_ISNULL(common_rpc = task_exec_ctx->get_common_rpc())) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("get common rpc proxy failed", KR(ret), K(task_exec_ctx));
|
||||
} else if (OB_ISNULL(GCTX.sql_proxy_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), KP(GCTX.sql_proxy_));
|
||||
} else if (OB_FAIL(common_rpc->admin_replace_arbitration_service(stmt.get_rpc_arg()))) {
|
||||
LOG_WARN("replace arbitration service rpc failed", KR(ret), "rpc_arg", stmt.get_rpc_arg());
|
||||
} else if (OB_FAIL(ObArbitrationServiceUtils::wait_all_tenant_with_arb_has_arb_member(
|
||||
*GCTX.sql_proxy_,
|
||||
stmt.get_rpc_arg().get_arbitration_service(),
|
||||
stmt.get_rpc_arg().get_previous_arbitration_service()))) {
|
||||
LOG_WARN("fail to wait all tenant with arb service has expected arb member",
|
||||
KR(ret), "rpc_arg", stmt.get_rpc_arg());
|
||||
} else {
|
||||
// try clean cluster info from arb server
|
||||
ObRemoveClusterInfoFromArbServerArg remove_cluster_info_arg;
|
||||
int tmp_ret = OB_SUCCESS; // for remove_cluster_info operation
|
||||
if (OB_TMP_FAIL(remove_cluster_info_arg.init(stmt.get_rpc_arg().get_previous_arbitration_service()))) {
|
||||
LOG_WARN("fail to init a rpc arg", K(tmp_ret), "rpc_arg", stmt.get_rpc_arg());
|
||||
} else if (OB_TMP_FAIL(common_rpc->remove_cluster_info_from_arb_server(remove_cluster_info_arg))) {
|
||||
LOG_WARN("fail to remove cluster info from arb server", K(tmp_ret), K(remove_cluster_info_arg));
|
||||
}
|
||||
if (OB_SUCCESS != tmp_ret) {
|
||||
LOG_USER_WARN(OB_CLUSTER_INFO_MAYBE_REMAINED, stmt.get_rpc_arg().get_previous_arbitration_service().length(),
|
||||
stmt.get_rpc_arg().get_previous_arbitration_service().ptr());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2146,6 +2251,13 @@ int ObDeletePolicyExecutor::execute(ObExecContext &ctx, ObDeletePolicyStmt &stmt
|
||||
int ObBackupKeyExecutor::execute(ObExecContext &ctx, ObBackupKeyStmt &stmt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
#ifdef OB_BUILD_TDE_SECURITY
|
||||
if (OB_FAIL(ObMasterKeyUtil::backup_key(stmt.get_tenant_id(),
|
||||
stmt.get_backup_dest(),
|
||||
stmt.get_encrypt_key()))) {
|
||||
LOG_WARN("failed to backup master key", K(ret));
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ int ObPhysicalRestoreTenantExecutor::execute(
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO: fix restore preview later.
|
||||
// TODO(chongrong.th): fix restore preview in 4.3
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("restore preview is not support now", K(ret));
|
||||
// if (OB_FAIL(physical_restore_preview(ctx, stmt))) {
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_ENGINE_CMD_TABLESPACE_CMD_EXECUTOR_
|
||||
#define OCEANBASE_SQL_ENGINE_CMD_TABLESPACE_CMD_EXECUTOR_
|
||||
#include "lib/string/ob_string.h"
|
||||
#include "lib/container/ob_array_serialization.h"
|
||||
#include "share/schema/ob_schema_struct.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace obrpc
|
||||
{
|
||||
class ObCommonRpcProxy;
|
||||
struct ObTablespaceDDLArg;
|
||||
}
|
||||
namespace sql
|
||||
{
|
||||
class ObExecContext;
|
||||
class ObCreateTablespaceStmt;
|
||||
class ObDropTablespaceStmt;
|
||||
class ObAlterTablespaceStmt;
|
||||
class ObCreateTablespaceExecutor
|
||||
{
|
||||
public:
|
||||
ObCreateTablespaceExecutor() {}
|
||||
virtual ~ObCreateTablespaceExecutor() {}
|
||||
int execute(ObExecContext &ctx, ObCreateTablespaceStmt &stmt);
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObCreateTablespaceExecutor);
|
||||
};
|
||||
|
||||
|
||||
class ObAlterTablespaceExecutor
|
||||
{
|
||||
public:
|
||||
ObAlterTablespaceExecutor() {}
|
||||
virtual ~ObAlterTablespaceExecutor() {}
|
||||
int execute(ObExecContext &ctx, ObAlterTablespaceStmt &stmt);
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObAlterTablespaceExecutor);
|
||||
};
|
||||
|
||||
|
||||
class ObDropTablespaceExecutor
|
||||
{
|
||||
public:
|
||||
ObDropTablespaceExecutor() {}
|
||||
virtual ~ObDropTablespaceExecutor() {}
|
||||
int execute(ObExecContext &ctx, ObDropTablespaceStmt &stmt);
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObDropTablespaceExecutor);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif //OCEANBASE_SQL_ENGINE_CMD_USER_CMD_EXECUTOR_
|
||||
@ -22,6 +22,10 @@
|
||||
#include "sql/resolver/tcl/ob_start_trans_stmt.h"
|
||||
#include "sql/resolver/tcl/ob_savepoint_stmt.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#ifdef OB_BUILD_ORACLE_PL
|
||||
#include "pl/sys_package/ob_dbms_xa.h"
|
||||
#include "sql/dblink/ob_tm_service.h"
|
||||
#endif
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -44,6 +48,50 @@ int ObEndTransExecutor::end_trans(ObExecContext &ctx, ObEndTransStmt &stmt)
|
||||
LOG_ERROR("session ptr is null", K(ret));
|
||||
} else if (my_session->is_in_transaction() &&
|
||||
my_session->associated_xa()) {
|
||||
#ifdef OB_BUILD_ORACLE_PL
|
||||
transaction::ObTxDesc *tx_desc = my_session->get_tx_desc();
|
||||
const transaction::ObXATransID xid = my_session->get_xid();
|
||||
const transaction::ObGlobalTxType global_tx_type = tx_desc->get_global_tx_type(xid);
|
||||
if (transaction::ObGlobalTxType::XA_TRANS == global_tx_type) {
|
||||
if (stmt.get_is_rollback()) {
|
||||
// rollback can be executed in xa trans
|
||||
// NOTE that rollback does not finish the xa trans,
|
||||
// it only rollbacks all actions of the trans
|
||||
if (OB_FAIL(pl::ObDbmsXA::xa_rollback_origin_savepoint(ctx))) {
|
||||
LOG_WARN("rollback xa changes failed", K(ret), K(xid), K(global_tx_type));
|
||||
}
|
||||
} else {
|
||||
// commit is not allowed in xa trans
|
||||
ret = OB_TRANS_XA_ERR_COMMIT;
|
||||
LOG_WARN("COMMIT is not allowed in a xa trans", K(ret), K(xid), K(global_tx_type),
|
||||
KPC(tx_desc));
|
||||
}
|
||||
} else if (transaction::ObGlobalTxType::DBLINK_TRANS == global_tx_type) {
|
||||
transaction::ObTransID tx_id;
|
||||
if (stmt.get_is_rollback()) {
|
||||
if (OB_FAIL(ObTMService::tm_rollback(ctx, tx_id))) {
|
||||
LOG_WARN("fail to do rollback for dblink trans", K(ret), K(tx_id), K(xid),
|
||||
K(global_tx_type));
|
||||
}
|
||||
my_session->restore_auto_commit();
|
||||
} else {
|
||||
if (OB_FAIL(ObTMService::tm_commit(ctx, tx_id))) {
|
||||
LOG_WARN("fail to do commit for dblink trans", K(ret), K(tx_id), K(xid),
|
||||
K(global_tx_type));
|
||||
}
|
||||
my_session->restore_auto_commit();
|
||||
}
|
||||
const bool force_disconnect = false;
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(OB_SUCCESS != (tmp_ret = my_session->get_dblink_context().clean_dblink_conn(force_disconnect)))) {
|
||||
LOG_WARN("dblink transaction failed to release dblink connections", K(tmp_ret), K(tx_id), K(xid));
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected global trans type", K(ret), K(xid), K(global_tx_type), KPC(tx_desc));
|
||||
}
|
||||
ctx.set_need_disconnect(false);
|
||||
#endif
|
||||
} else if (OB_FAIL(ObSqlTransControl::explicit_end_trans(ctx, stmt.get_is_rollback(), stmt.get_hint()))) {
|
||||
LOG_WARN("fail end trans", K(ret));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user