Fix stale tenant id in alter_table_arg after standby tenant switchover

This commit is contained in:
Hongqin-Li
2023-03-02 14:59:50 +00:00
committed by ob-robot
parent 619143a16f
commit 8ea5392a4d
5 changed files with 14 additions and 0 deletions

View File

@ -271,6 +271,7 @@ int ObColumnRedefinitionTask::copy_table_indexes()
alter_table_arg_.ddl_task_type_ = share::REBUILD_INDEX_TASK;
alter_table_arg_.table_id_ = object_id_;
alter_table_arg_.hidden_table_id_ = target_object_id_;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
if (OB_FAIL(root_service->get_ddl_service().get_tenant_schema_guard_with_version_in_inner_table(tenant_id_, schema_guard))) {
LOG_WARN("get schema guard failed", K(ret));
} else if (OB_FAIL(schema_guard.get_table_schema(tenant_id_, target_object_id_, table_schema))) {
@ -410,6 +411,7 @@ int ObColumnRedefinitionTask::copy_table_constraints()
alter_table_arg_.ddl_task_type_ = share::REBUILD_CONSTRAINT_TASK;
alter_table_arg_.table_id_ = object_id_;
alter_table_arg_.hidden_table_id_ = target_object_id_;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, target_object_id_, rpc_timeout))) {
LOG_WARN("get ddl rpc timeout failed", K(ret));
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
@ -457,6 +459,7 @@ int ObColumnRedefinitionTask::copy_table_foreign_keys()
alter_table_arg_.ddl_task_type_ = share::REBUILD_FOREIGN_KEY_TASK;
alter_table_arg_.table_id_ = object_id_;
alter_table_arg_.hidden_table_id_ = target_object_id_;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, target_object_id_, rpc_timeout))) {
LOG_WARN("get ddl rpc timeout failed", K(ret));
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
@ -602,6 +605,7 @@ int ObColumnRedefinitionTask::take_effect(const ObDDLTaskStatus next_task_status
alter_table_arg_.hidden_table_id_ = target_object_id_;
// offline ddl is allowed on table with trigger(enable/disable).
alter_table_arg_.need_rebuild_trigger_ = true;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
ObRootService *root_service = GCTX.root_service_;
ObSchemaGetterGuard schema_guard;
const ObTableSchema *table_schema = nullptr;

View File

@ -1048,6 +1048,7 @@ int ObConstraintTask::set_foreign_key_constraint_validated()
fk_arg.need_validate_data_ = false;
alter_table_arg.exec_tenant_id_ = tenant_id_;
alter_table_arg.based_schema_object_infos_.reset();
alter_table_arg.alter_table_schema_.set_tenant_id(tenant_id_);
if (is_table_hidden_) {
ObSArray<uint64_t> unused_ids;
alter_table_arg.ddl_task_type_ = share::MODIFY_FOREIGN_KEY_STATE_TASK;
@ -1121,6 +1122,7 @@ int ObConstraintTask::set_check_constraint_validated()
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, object_id_, rpc_timeout))) {
LOG_WARN("get ddl rpc timeout failed", K(ret));
} else if (CONSTRAINT_TYPE_NOT_NULL == (*iter)->get_constraint_type()) {
alter_table_arg.alter_table_schema_.set_tenant_id(tenant_id_);
if (is_table_hidden_) {
if (!is_oracle_mode) {
// only mysql mode support modify not null column during offline ddl, support oracle later.
@ -1399,6 +1401,7 @@ int ObConstraintTask::rollback_failed_foregin_key()
ObSArray<uint64_t> unused_ids;
alter_table_arg.ddl_task_type_ = share::MODIFY_FOREIGN_KEY_STATE_TASK;
alter_table_arg.hidden_table_id_ = object_id_;
alter_table_arg.alter_table_schema_.set_tenant_id(tenant_id_);
if (OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
execute_ddl_task(alter_table_arg, unused_ids))) {
LOG_WARN("alter table failed", K(ret));
@ -1485,6 +1488,7 @@ int ObConstraintTask::rollback_failed_add_not_null_columns()
alter_table_arg.ddl_task_type_ = share::DELETE_COLUMN_FROM_SCHEMA;
alter_table_arg.index_arg_list_.reset();
alter_table_arg.foreign_key_arg_list_.reset();
alter_table_arg.alter_table_schema_.set_tenant_id(tenant_id_);
AlterColumnSchema *col_schema = NULL;
for (int64_t i = 0; i < alter_table_arg.alter_table_schema_.get_column_count() && OB_SUCC(ret); i++) {
if (OB_ISNULL(col_schema = static_cast<AlterColumnSchema *>(

View File

@ -1221,6 +1221,7 @@ int ObDDLRedefinitionTask::finish()
alter_table_arg_.ddl_task_type_ = share::CLEANUP_GARBAGE_TASK;
alter_table_arg_.table_id_ = object_id_;
alter_table_arg_.hidden_table_id_ = target_object_id_;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
ObRootService *root_service = GCTX.root_service_;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;

View File

@ -465,6 +465,7 @@ int ObModifyAutoincTask::set_schema_available()
} else {
ObSArray<uint64_t> unused_ids;
alter_table_arg_.ddl_task_type_ = share::UPDATE_AUTOINC_SCHEMA;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, object_id_, rpc_timeout))) {
LOG_WARN("get rpc timeout failed", K(ret));
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).

View File

@ -392,6 +392,7 @@ int ObTableRedefinitionTask::copy_table_indexes()
alter_table_arg_.ddl_task_type_ = share::REBUILD_INDEX_TASK;
alter_table_arg_.table_id_ = object_id_;
alter_table_arg_.hidden_table_id_ = target_object_id_;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
if (OB_FAIL(root_service->get_ddl_service().get_tenant_schema_guard_with_version_in_inner_table(tenant_id_, schema_guard))) {
LOG_WARN("get schema guard failed", K(ret));
} else if (OB_FAIL(schema_guard.get_table_schema(tenant_id_, target_object_id_, table_schema))) {
@ -528,6 +529,7 @@ int ObTableRedefinitionTask::copy_table_constraints()
alter_table_arg_.ddl_task_type_ = share::REBUILD_CONSTRAINT_TASK;
alter_table_arg_.table_id_ = object_id_;
alter_table_arg_.hidden_table_id_ = target_object_id_;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
int64_t ddl_rpc_timeout = 0;
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, target_object_id_, ddl_rpc_timeout))) {
LOG_WARN("get ddl rpc timeout fail", K(ret));
@ -599,6 +601,7 @@ int ObTableRedefinitionTask::copy_table_foreign_keys()
alter_table_arg_.ddl_task_type_ = share::REBUILD_FOREIGN_KEY_TASK;
alter_table_arg_.table_id_ = object_id_;
alter_table_arg_.hidden_table_id_ = target_object_id_;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
int64_t ddl_rpc_timeout = 0;
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, target_object_id_, ddl_rpc_timeout))) {
LOG_WARN("get ddl rpc timeout fail", K(ret));
@ -719,6 +722,7 @@ int ObTableRedefinitionTask::take_effect(const ObDDLTaskStatus next_task_status)
alter_table_arg_.hidden_table_id_ = target_object_id_;
// offline ddl is allowed on table with trigger(enable/disable).
alter_table_arg_.need_rebuild_trigger_ = true;
alter_table_arg_.alter_table_schema_.set_tenant_id(tenant_id_);
ObRootService *root_service = GCTX.root_service_;
ObSchemaGetterGuard schema_guard;
const ObTableSchema *table_schema = nullptr;