fix ddl rpc timeout bug
This commit is contained in:
parent
d65939897e
commit
58875bd2b7
@ -241,6 +241,7 @@ int ObColumnRedefinitionTask::update_complete_sstable_job_status(const common::O
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// Now, rebuild index table in schema and tablet.
|
||||
// Next, we only rebuild index in schema and remap new index schema to old tablet by sending RPC(REMAP_INDEXES_AND_TAKE_EFFECT_TASK) to RS.
|
||||
int ObColumnRedefinitionTask::copy_table_indexes()
|
||||
@ -282,7 +283,13 @@ int ObColumnRedefinitionTask::copy_table_indexes()
|
||||
LOG_INFO("indexes schema are already built", K(index_ids));
|
||||
} else {
|
||||
// if there is no indexes in new tables, we need to rebuild indexes in new table
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t all_tablet_count = 0;
|
||||
if (OB_FAIL(get_orig_all_index_tablet_count(schema_guard, all_tablet_count))) {
|
||||
LOG_WARN("get all tablet count failed", K(ret));
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(all_tablet_count, 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).
|
||||
execute_ddl_task(alter_table_arg_, index_ids))) {
|
||||
LOG_WARN("rebuild hidden table index failed", K(ret));
|
||||
}
|
||||
@ -365,6 +372,7 @@ int ObColumnRedefinitionTask::copy_table_indexes()
|
||||
int ObColumnRedefinitionTask::copy_table_constraints()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
ObRootService *root_service = GCTX.root_service_;
|
||||
const ObTableSchema *table_schema = nullptr;
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
@ -395,7 +403,9 @@ 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_;
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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).
|
||||
execute_ddl_task(alter_table_arg_, constraint_ids))) {
|
||||
LOG_WARN("rebuild hidden table constraint failed", K(ret));
|
||||
}
|
||||
@ -414,6 +424,7 @@ int ObColumnRedefinitionTask::copy_table_constraints()
|
||||
int ObColumnRedefinitionTask::copy_table_foreign_keys()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
ObRootService *root_service = GCTX.root_service_;
|
||||
const ObSimpleTableSchemaV2 *table_schema = nullptr;
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
@ -439,7 +450,9 @@ 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_;
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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).
|
||||
execute_ddl_task(alter_table_arg_, fk_ids))) {
|
||||
LOG_WARN("rebuild hidden table constraint failed", K(ret));
|
||||
}
|
||||
@ -575,6 +588,7 @@ int ObColumnRedefinitionTask::copy_table_dependent_objects(const ObDDLTaskStatus
|
||||
int ObColumnRedefinitionTask::take_effect(const ObDDLTaskStatus next_task_status)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
ObSArray<uint64_t> objs;
|
||||
alter_table_arg_.ddl_task_type_ = share::MAKE_DDL_TAKE_EFFECT_TASK;
|
||||
alter_table_arg_.table_id_ = object_id_;
|
||||
@ -616,7 +630,9 @@ int ObColumnRedefinitionTask::take_effect(const ObDDLTaskStatus next_task_status
|
||||
}
|
||||
} else if (OB_FAIL(sync_stats_info())) {
|
||||
LOG_WARN("fail to sync stats info", K(ret), K(object_id_), K(target_object_id_));
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
} else 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).
|
||||
execute_ddl_task(alter_table_arg_, objs))) {
|
||||
LOG_WARN("fail to swap original and hidden table state", K(ret));
|
||||
if (OB_TIMEOUT == ret) {
|
||||
|
@ -1020,6 +1020,8 @@ int ObConstraintTask::report_foreign_key_constraint_error_code()
|
||||
int ObConstraintTask::set_foreign_key_constraint_validated()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t tablet_count = 0;
|
||||
ObRootService *root_service = GCTX.root_service_;
|
||||
obrpc::ObAlterTableRes res;
|
||||
ObArenaAllocator allocator(lib::ObLabel("ConstraiTask"));
|
||||
@ -1032,6 +1034,8 @@ int ObConstraintTask::set_foreign_key_constraint_validated()
|
||||
} else if (OB_ISNULL(root_service)) {
|
||||
ret = OB_ERR_SYS;
|
||||
LOG_WARN("error sys, root serivce must not be nullptr", K(ret));
|
||||
} 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 {
|
||||
DEBUG_SYNC(CONSTRAINT_BEFORE_SET_FK_VALIDATED_BEFORE_ALTER_TABLE);
|
||||
ObCreateForeignKeyArg &fk_arg = alter_table_arg.foreign_key_arg_list_.at(0);
|
||||
@ -1045,14 +1049,14 @@ int ObConstraintTask::set_foreign_key_constraint_validated()
|
||||
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_;
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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("fail to alter table", K(ret), K(alter_table_arg), K(fk_arg));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(ObDDLUtil::refresh_alter_table_arg(tenant_id_, object_id_, alter_table_arg))) {
|
||||
LOG_WARN("failed to refresh name for alter table schema", K(ret));
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
|
||||
alter_table(alter_table_arg, res))) {
|
||||
LOG_WARN("alter table failed", K(ret));
|
||||
}
|
||||
@ -1068,6 +1072,8 @@ int ObConstraintTask::set_check_constraint_validated()
|
||||
ObRootService *root_service = GCTX.root_service_;
|
||||
obrpc::ObAlterTableRes res;
|
||||
bool is_oracle_mode = false;
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t tablet_count = 0;
|
||||
ObArenaAllocator allocator(lib::ObLabel("ConstraiTask"));
|
||||
SMART_VAR(ObAlterTableArg, alter_table_arg) {
|
||||
if (OB_ISNULL(root_service)) {
|
||||
@ -1109,6 +1115,8 @@ int ObConstraintTask::set_check_constraint_validated()
|
||||
LOG_WARN("constraint not found", K(ret), K(target_object_id_), K(alter_table_arg));
|
||||
} else if (OB_FAIL(alter_table_arg.alter_table_schema_.check_if_oracle_compat_mode(is_oracle_mode))) {
|
||||
LOG_WARN("check if oracle compat mode failed", K(ret));
|
||||
} 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()) {
|
||||
if (is_table_hidden_) {
|
||||
if (!is_oracle_mode) {
|
||||
@ -1116,7 +1124,7 @@ int ObConstraintTask::set_check_constraint_validated()
|
||||
ObSArray<uint64_t> unused_ids;
|
||||
alter_table_arg.ddl_task_type_ = share::MODIFY_NOT_NULL_COLUMN_STATE_TASK;
|
||||
alter_table_arg.hidden_table_id_ = object_id_;
|
||||
if (OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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));
|
||||
if (OB_TABLE_NOT_EXIST == ret) {
|
||||
@ -1160,7 +1168,7 @@ int ObConstraintTask::set_check_constraint_validated()
|
||||
}
|
||||
DEBUG_SYNC(CONSTRAINT_BEFORE_SET_CHECK_CONSTRAINT_VALIDATED_BEFORE_ALTER_TABLE);
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
|
||||
alter_table(alter_table_arg, res))) {
|
||||
LOG_WARN("alter table failed", K(ret));
|
||||
}
|
||||
@ -1175,6 +1183,8 @@ int ObConstraintTask::set_check_constraint_validated()
|
||||
int ObConstraintTask::set_new_not_null_column_validate()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t tablet_count = 0;
|
||||
ObRootService *root_service = GCTX.root_service_;
|
||||
obrpc::ObAlterTableRes res;
|
||||
ObArenaAllocator allocator(lib::ObLabel("ConstraiTask"));
|
||||
@ -1219,7 +1229,9 @@ int ObConstraintTask::set_new_not_null_column_validate()
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
} 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 (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
|
||||
alter_table(alter_table_arg, res))) {
|
||||
LOG_WARN("alter table failed", K(ret));
|
||||
} else {
|
||||
@ -1261,6 +1273,8 @@ int ObConstraintTask::rollback_failed_schema()
|
||||
int ObConstraintTask::rollback_failed_check_constraint()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t tablet_count = 0;
|
||||
obrpc::ObAlterTableRes tmp_res;
|
||||
ObArenaAllocator allocator(lib::ObLabel("ConstraiTask"));
|
||||
SMART_VAR(ObAlterTableArg, alter_table_arg) {
|
||||
@ -1312,7 +1326,9 @@ int ObConstraintTask::rollback_failed_check_constraint()
|
||||
alter_table_arg.is_alter_columns_ = false;
|
||||
alter_table_arg.index_arg_list_.reset();
|
||||
alter_table_arg.foreign_key_arg_list_.reset();
|
||||
if (OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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 (OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
|
||||
alter_table(alter_table_arg, tmp_res))) {
|
||||
LOG_WARN("alter table failed", K(ret));
|
||||
if (OB_TABLE_NOT_EXIST == ret || OB_ERR_CANT_DROP_FIELD_OR_KEY == ret || OB_ERR_CONTRAINT_NOT_FOUND == ret) {
|
||||
@ -1333,6 +1349,8 @@ int ObConstraintTask::rollback_failed_check_constraint()
|
||||
int ObConstraintTask::rollback_failed_foregin_key()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t tablet_count = 0;
|
||||
obrpc::ObAlterTableRes tmp_res;
|
||||
obrpc::ObDropForeignKeyArg drop_foreign_key_arg;
|
||||
ObCreateForeignKeyArg &fk_arg = alter_table_arg_.foreign_key_arg_list_.at(0);
|
||||
@ -1368,13 +1386,17 @@ int ObConstraintTask::rollback_failed_foregin_key()
|
||||
}
|
||||
}
|
||||
DEBUG_SYNC(CONSTRAINT_ROLLBACK_FAILED_FK_BEFORE_ALTER_TABLE);
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, object_id_, rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout failed", K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
alter_table_arg.is_inner_ = true;
|
||||
if (is_table_hidden_) {
|
||||
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_;
|
||||
if (OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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));
|
||||
if (OB_TABLE_NOT_EXIST == ret || OB_ERR_CANT_DROP_FIELD_OR_KEY == ret) {
|
||||
@ -1388,7 +1410,7 @@ int ObConstraintTask::rollback_failed_foregin_key()
|
||||
} else {
|
||||
LOG_WARN("failed to refresh name for alter table schema", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
} else if (OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
|
||||
alter_table(alter_table_arg, tmp_res))) {
|
||||
LOG_WARN("alter table failed", K(ret));
|
||||
if (OB_TABLE_NOT_EXIST == ret || OB_ERR_CANT_DROP_FIELD_OR_KEY == ret) {
|
||||
@ -1450,6 +1472,8 @@ int ObConstraintTask::rollback_failed_add_not_null_columns()
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t tablet_count = 0;
|
||||
obrpc::ObAlterTableRes tmp_res;
|
||||
ObSArray<uint64_t> objs;
|
||||
alter_table_arg.ddl_stmt_str_.assign_ptr(buf, static_cast<int32_t>(pos));
|
||||
@ -1470,8 +1494,12 @@ int ObConstraintTask::rollback_failed_add_not_null_columns()
|
||||
col_schema->get_column_name_str().length());
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, object_id_, rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout failed", K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret)
|
||||
&& OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
&& OB_FAIL(root_service_->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
|
||||
execute_ddl_task(alter_table_arg, objs))) {
|
||||
LOG_WARN("alter table failed", K(ret));
|
||||
if (OB_TABLE_NOT_EXIST == ret || OB_ERR_CANT_DROP_FIELD_OR_KEY == ret) {
|
||||
|
@ -224,6 +224,8 @@ int ObDDLRedefinitionTask::prepare(const ObDDLTaskStatus next_task_status)
|
||||
int ObDDLRedefinitionTask::lock_table(const ObDDLTaskStatus next_task_status)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t target_rpc_timeout = 0;
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
const ObTableSchema *data_table_schema = nullptr;
|
||||
const ObTableSchema *dest_table_schema = nullptr;
|
||||
@ -246,8 +248,10 @@ int ObDDLRedefinitionTask::lock_table(const ObDDLTaskStatus next_task_status)
|
||||
LOG_WARN("table type is different", K(ret), K(data_table_schema->is_tmp_table()), K(dest_table_schema->is_tmp_table()));
|
||||
} else if (data_table_schema->is_tmp_table()) {
|
||||
// no need to lock table and unlock table.
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, object_id_, rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout fail", K(ret));
|
||||
} else if (OB_FAIL(ObTableLockRpcClient::get_instance().lock_table(object_id_,
|
||||
EXCLUSIVE, schema_version_, 0, tenant_id_))) {
|
||||
EXCLUSIVE, schema_version_, rpc_timeout, tenant_id_))) {
|
||||
if (!ObDDLUtil::is_table_lock_retry_ret_code(ret)) {
|
||||
LOG_WARN("lock source table failed", K(ret), K(object_id_));
|
||||
} else {
|
||||
@ -256,8 +260,10 @@ int ObDDLRedefinitionTask::lock_table(const ObDDLTaskStatus next_task_status)
|
||||
LOG_INFO("cannot lock source table", K(ret), K(object_id_));
|
||||
}
|
||||
}
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, target_object_id_, target_rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout fail", K(ret));
|
||||
} else if (OB_FAIL(ObTableLockRpcClient::get_instance().lock_table(target_object_id_,
|
||||
EXCLUSIVE, schema_version_, 0, tenant_id_))) {
|
||||
EXCLUSIVE, schema_version_, target_rpc_timeout, tenant_id_))) {
|
||||
if (!ObDDLUtil::is_table_lock_retry_ret_code(ret)) {
|
||||
LOG_WARN("lock dest table failed", K(ret), K(target_object_id_));
|
||||
} else {
|
||||
@ -1207,6 +1213,8 @@ int ObDDLRedefinitionTask::finish()
|
||||
ObSchemaGetterGuard schema_guard;
|
||||
const ObTableSchema *data_table_schema = nullptr;
|
||||
ObSArray<uint64_t> objs;
|
||||
int64_t rpc_timeout = 0;
|
||||
int64_t all_orig_index_tablet_count = 0;
|
||||
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_;
|
||||
@ -1225,8 +1233,12 @@ int ObDDLRedefinitionTask::finish()
|
||||
LOG_WARN("get schema guard failed", K(ret), K(tenant_id_));
|
||||
} else if (OB_FAIL(schema_guard.get_table_schema(tenant_id_, object_id_, data_table_schema))) {
|
||||
LOG_WARN("get data table schema failed", K(ret), K(tenant_id_), K(object_id_));
|
||||
} else if (OB_FAIL(get_orig_all_index_tablet_count(schema_guard, all_orig_index_tablet_count))) {
|
||||
LOG_WARN("get orig all tablet count failed", K(ret));
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(max(all_orig_index_tablet_count, data_table_schema->get_all_part_num()), rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout failed", K(ret));
|
||||
} else if (nullptr != data_table_schema && data_table_schema->get_association_table_id() != OB_INVALID_ID &&
|
||||
OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(rpc_timeout).
|
||||
execute_ddl_task(alter_table_arg_, objs))) {
|
||||
LOG_WARN("cleanup garbage failed", K(ret));
|
||||
} else if (OB_FAIL(cleanup())) {
|
||||
@ -1366,6 +1378,31 @@ int ObDDLRedefinitionTask::get_estimated_timeout(const ObTableSchema *dst_table_
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLRedefinitionTask::get_orig_all_index_tablet_count(ObSchemaGetterGuard &schema_guard, int64_t &all_tablet_count)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObTableSchema *orig_table_schema = nullptr;
|
||||
all_tablet_count = 0;
|
||||
if (OB_FAIL(schema_guard.get_table_schema(tenant_id_, object_id_, orig_table_schema))) {
|
||||
LOG_WARN("get table schema failed", K(ret), K(tenant_id_), K(object_id_));
|
||||
} else if (OB_ISNULL(orig_table_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("error unexpected, table schema must not be nullptr", K(ret), K(object_id_));
|
||||
} else {
|
||||
const common::ObIArray<ObAuxTableMetaInfo> &orig_index_infos = orig_table_schema->get_simple_index_infos();
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < orig_index_infos.count(); i++) {
|
||||
int64_t tablet_count = 0;
|
||||
int64_t table_id = orig_index_infos.at(i).table_id_;
|
||||
if (OB_FAIL(ObDDLUtil::get_tablet_count(tenant_id_, table_id, tablet_count))) {
|
||||
LOG_WARN("get tablet count fail", K(ret));
|
||||
} else {
|
||||
all_tablet_count += tablet_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLRedefinitionTask::sync_stats_info()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -1839,7 +1876,7 @@ int ObDDLRedefinitionTask::check_need_rebuild_constraint(const ObTableSchema &ta
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int ObDDLRedefinitionTask::check_need_check_table_empty(bool &need_check_table_empty)
|
||||
{
|
||||
@ -2005,8 +2042,9 @@ template<typename P, typename A>
|
||||
int ObSyncTabletAutoincSeqCtx::call_and_process_all_tablet_autoinc_seqs(P &proxy, A &arg, const bool is_get)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t rpc_timeout = ObDDLUtil::get_ddl_rpc_timeout();
|
||||
int64_t rpc_timeout = 0;
|
||||
const bool force_renew = false;
|
||||
const int64_t tablet_count = src_tablet_ids_.count();
|
||||
share::ObLocationService *location_service = nullptr;
|
||||
ObHashMap<ObLSID, ObSEArray<ObMigrateTabletAutoincSeqParam, 1>> ls_to_tablet_map;
|
||||
if (OB_ISNULL(location_service = GCTX.location_service_)) {
|
||||
@ -2014,6 +2052,8 @@ int ObSyncTabletAutoincSeqCtx::call_and_process_all_tablet_autoinc_seqs(P &proxy
|
||||
LOG_WARN("location_cache is null", K(ret));
|
||||
} else if (OB_FAIL(ls_to_tablet_map.create(MAP_BUCKET_NUM, "DDLRedefTmp"))) {
|
||||
LOG_WARN("failed to create map", K(ret));
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tablet_count, rpc_timeout))) {
|
||||
LOG_WARN("failed to get ddl rpc timeout", K(ret));
|
||||
} else {
|
||||
if (is_get) {
|
||||
ObSEArray<ObMigrateTabletAutoincSeqParam, 1> tmp_autoinc_params;
|
||||
|
@ -193,6 +193,7 @@ protected:
|
||||
int check_need_check_table_empty(bool &need_check_table_empty);
|
||||
int get_child_task_ids(char *buf, int64_t len);
|
||||
int get_estimated_timeout(const share::schema::ObTableSchema *dst_table_schema, int64_t &estimated_timeout);
|
||||
int get_orig_all_index_tablet_count(ObSchemaGetterGuard &schema_guard, int64_t &all_tablet_count);
|
||||
protected:
|
||||
struct DependTaskStatus final
|
||||
{
|
||||
|
@ -454,6 +454,7 @@ int ObPrepareAlterTableArgParam::set_nls_formats(const common::ObString *nls_for
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(nls_formats)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("nls_formats is nullptr", K(ret));
|
||||
} else {
|
||||
char *tmp_ptr[ObNLSFormatEnum::NLS_MAX] = {};
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < ObNLSFormatEnum::NLS_MAX; ++i) {
|
||||
|
@ -90,7 +90,7 @@ int ObDDLSingleReplicaExecutor::schedule_task()
|
||||
common::ObIArray<ObPartitionBuildInfo> &build_infos = partition_build_stat_;
|
||||
ObArray<int64_t> idxs;
|
||||
const int64_t current_time = ObTimeUtility::current_time();
|
||||
const int64_t rpc_timeout = ObDDLUtil::get_ddl_rpc_timeout();
|
||||
int64_t rpc_timeout = ObDDLUtil::get_default_ddl_rpc_timeout();
|
||||
const bool force_renew = true;
|
||||
bool is_cache_hit = false;
|
||||
const int64_t expire_renew_time = force_renew ? INT64_MAX : 0;
|
||||
@ -127,7 +127,7 @@ int ObDDLSingleReplicaExecutor::schedule_task()
|
||||
LOG_WARN("get leader failed", K(ret), K(tenant_id_), K(ls_id));
|
||||
} else if (FALSE_IT(arg.ls_id_ = ls_id)) {
|
||||
} else if (OB_FAIL(proxy.call(leader_addr, rpc_timeout, tenant_id_, arg))) {
|
||||
LOG_WARN("fail to send rpc", K(ret));
|
||||
LOG_WARN("fail to send rpc", K(ret), K(rpc_timeout));
|
||||
} else if (OB_FAIL(idxs.push_back(i))) {
|
||||
LOG_WARN("fail to push back idx", K(ret));
|
||||
} else {
|
||||
|
@ -1100,11 +1100,19 @@ int ObDDLTask::batch_release_snapshot(
|
||||
ObMySQLTransaction trans;
|
||||
ObRootService *root_service = GCTX.root_service_;
|
||||
SCN snapshot_scn;
|
||||
ObTimeoutCtx timeout_ctx;
|
||||
int64_t timeout = 0;
|
||||
if (OB_ISNULL(root_service)) {
|
||||
ret = OB_ERR_SYS;
|
||||
LOG_WARN("error sys, root service must not be nullptr", K(ret));
|
||||
} else if (OB_FAIL(snapshot_scn.convert_for_tx(snapshot_version))) {
|
||||
LOG_WARN("failed to convert scn", K(snapshot_scn), K(ret));
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_tx_timeout(tablet_ids.count(), timeout))) {
|
||||
LOG_WARN("get ddl tx timeout failed", K(ret));
|
||||
} else if (OB_FAIL(timeout_ctx.set_trx_timeout_us(timeout))) {
|
||||
LOG_WARN("set timeout ctx failed", K(ret));
|
||||
} else if (OB_FAIL(timeout_ctx.set_timeout(timeout))) {
|
||||
LOG_WARN("set timeout failed", K(ret));
|
||||
} else if (OB_FAIL(trans.start(&root_service->get_ddl_service().get_sql_proxy(), tenant_id_))) {
|
||||
LOG_WARN("fail to start trans", K(ret));
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_snapshot_mgr().batch_release_snapshot_in_trans(
|
||||
@ -1195,9 +1203,11 @@ int ObDDLTask::push_execution_id(const uint64_t tenant_id, const int64_t task_id
|
||||
// The length of [min_dt, max_dt] controls the execution rate of ddl tasks.
|
||||
void ObDDLTask::calc_next_schedule_ts(const int ret_code, const int64_t total_task_cnt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t ddl_rpc_timeout = ObDDLUtil::get_default_ddl_rpc_timeout();
|
||||
if (OB_TIMEOUT == ret_code) {
|
||||
const int64_t SEC = 1000000;
|
||||
const int64_t max_delay = total_task_cnt * ObDDLUtil::get_ddl_rpc_timeout() * 10;
|
||||
const int64_t max_delay = total_task_cnt * ddl_rpc_timeout * 10;
|
||||
delay_schedule_time_ = std::min(delay_schedule_time_ * 6/5 + SEC/10, max_delay);
|
||||
const int64_t max_dt = delay_schedule_time_;
|
||||
const int64_t min_dt = max_dt / 2;
|
||||
@ -1536,7 +1546,7 @@ int group_tablets_leader_addr(const uint64_t tenant_id, const ObIArray<ObTabletI
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(tenant_id), K(tablet_ids.count()));
|
||||
} else {
|
||||
const int64_t rpc_timeout = ObDDLUtil::get_ddl_rpc_timeout();
|
||||
int64_t rpc_timeout = ObDDLUtil::get_default_ddl_rpc_timeout();
|
||||
if (OB_FAIL(group_items.reserve(tablet_ids.count()))) {
|
||||
LOG_WARN("reserve send array failed", K(ret), K(tablet_ids.count()));
|
||||
}
|
||||
@ -1569,6 +1579,7 @@ int check_trans_end(const ObArray<SendItem> &send_array,
|
||||
transaction::ObTransID &pending_tx_id)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t rpc_timeout = 0;
|
||||
ret_array.reuse();
|
||||
snapshot_array.reuse();
|
||||
hash::ObHashMap<obrpc::ObLSTabletPair, obrpc::ObCheckTransElapsedResult> result_map;
|
||||
@ -1581,10 +1592,11 @@ int check_trans_end(const ObArray<SendItem> &send_array,
|
||||
LOG_WARN("copy send array failed", K(ret), K(send_array.count()));
|
||||
} else if (OB_FAIL(result_map.create(send_array.count(), "check_trans_map"))) {
|
||||
LOG_WARN("create return code map failed", K(ret));
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(arg.tablets_.count(), rpc_timeout))) {
|
||||
LOG_WARN("get_ddl_rpc_timeout_failed", K(ret));
|
||||
} else {
|
||||
// group by leader addr and send batch rpc
|
||||
std::sort(tmp_send_array.begin(), tmp_send_array.end());
|
||||
const int64_t rpc_timeout = ObDDLUtil::get_ddl_rpc_timeout();
|
||||
ObAddr last_addr;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < tmp_send_array.count(); ++i) {
|
||||
const SendItem &send_item = tmp_send_array.at(i);
|
||||
@ -1744,6 +1756,7 @@ int ObDDLWaitTransEndCtx::check_sstable_trans_end(
|
||||
int ObDDLWaitTransEndCtx::try_wait(bool &is_trans_end, int64_t &snapshot_version, const bool need_wait_trans_end)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t tablet_count = 0;
|
||||
is_trans_end = false;
|
||||
snapshot_version = 0;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
@ -1792,6 +1805,7 @@ int ObDDLWaitTransEndCtx::try_wait(bool &is_trans_end, int64_t &snapshot_version
|
||||
K(check_count), K(ret_codes.count()), K(tmp_snapshots.count()));
|
||||
} else {
|
||||
int64_t succ_count = 0;
|
||||
tablet_count = check_count;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < check_count; ++i) {
|
||||
if (OB_SUCCESS == ret_codes.at(i) && tmp_snapshots.at(i) > 0) {
|
||||
snapshot_array_.at(tablet_pos_indexes.at(i)) = tmp_snapshots.at(i);
|
||||
@ -1832,7 +1846,7 @@ int ObDDLWaitTransEndCtx::get_snapshot(int64_t &snapshot_version)
|
||||
ObRootService *root_service = nullptr;
|
||||
ObFreezeInfoProxy freeze_info_proxy(tenant_id_);
|
||||
ObSimpleFrozenStatus frozen_status;
|
||||
const int64_t timeout = ObDDLUtil::get_ddl_rpc_timeout();
|
||||
const int64_t timeout_us = ObDDLUtil::get_default_ddl_rpc_timeout();
|
||||
SCN curr_ts;
|
||||
bool is_external_consistent = false;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
@ -1851,10 +1865,10 @@ int ObDDLWaitTransEndCtx::get_snapshot(int64_t &snapshot_version)
|
||||
// for performance, everywhere calls get_ts_sync should ensure using correct tenant ctx
|
||||
tenant_guard.switch_to(tenant_id_);
|
||||
if (OB_FAIL(OB_TS_MGR.get_ts_sync(tenant_id_,
|
||||
timeout,
|
||||
timeout_us,
|
||||
curr_ts,
|
||||
is_external_consistent))) {
|
||||
LOG_WARN("fail to get gts sync", K(ret), K(tenant_id_), K(timeout), K(curr_ts), K(is_external_consistent));
|
||||
LOG_WARN("fail to get gts sync", K(ret), K(tenant_id_), K(timeout_us), K(curr_ts), K(is_external_consistent));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -2126,8 +2140,11 @@ int send_batch_calc_rpc(obrpc::ObSrvRpcProxy &rpc_proxy,
|
||||
int64_t &send_succ_count)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t rpc_timeout = ObDDLUtil::get_ddl_rpc_timeout();
|
||||
if (OB_FAIL(rpc_proxy.to(leader_addr)
|
||||
int64_t rpc_timeout = 0;
|
||||
const int64_t tablet_count = arg.calc_items_.count();
|
||||
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tablet_count, rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout failed", K(ret));
|
||||
} else if (OB_FAIL(rpc_proxy.to(leader_addr)
|
||||
.by(arg.tenant_id_)
|
||||
.timeout(rpc_timeout)
|
||||
.calc_column_checksum_request(arg, res))) {
|
||||
@ -2174,7 +2191,7 @@ int ObDDLWaitColumnChecksumCtx::send_calc_rpc(int64_t &send_succ_count)
|
||||
LOG_WARN("root service or location_cache is null", K(ret), KP(root_service), KP(location_service));
|
||||
} else {
|
||||
ObLSID ls_id;
|
||||
const int64_t rpc_timeout = ObDDLUtil::get_ddl_rpc_timeout();
|
||||
int64_t rpc_timeout = ObDDLUtil::get_default_ddl_rpc_timeout();
|
||||
ObArray<SendItem> send_array;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < stat_array_.count(); ++i) {
|
||||
PartitionColChecksumStat &item = stat_array_.at(i);
|
||||
|
@ -136,9 +136,12 @@ int ObDropIndexTask::update_index_status(const ObIndexStatus new_status)
|
||||
arg.status_ = new_status;
|
||||
arg.exec_tenant_id_ = tenant_id_;
|
||||
arg.in_offline_ddl_white_list_ = index_schema->get_table_state_flag() != TABLE_STATE_NORMAL;
|
||||
|
||||
int64_t ddl_rpc_timeout = 0;
|
||||
int64_t table_id = index_schema->get_table_id();
|
||||
DEBUG_SYNC(BEFORE_UPDATE_GLOBAL_INDEX_STATUS);
|
||||
if (OB_FAIL(root_service_->get_common_rpc_proxy().to(GCTX.self_addr()).timeout(ObDDLUtil::get_ddl_rpc_timeout()).update_index_status(arg))) {
|
||||
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, table_id, ddl_rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout fail", K(ret));
|
||||
} else if (OB_FAIL(root_service_->get_common_rpc_proxy().to(GCTX.self_addr()).timeout(ddl_rpc_timeout).update_index_status(arg))) {
|
||||
LOG_WARN("update index status failed", K(ret), K(arg));
|
||||
} else {
|
||||
LOG_INFO("notify index status changed finish", K(new_status), K(target_object_id_));
|
||||
|
@ -1175,9 +1175,13 @@ int ObIndexBuildTask::update_index_status_in_schema(const ObTableSchema &index_s
|
||||
arg.status_ = new_status;
|
||||
arg.exec_tenant_id_ = tenant_id_;
|
||||
arg.in_offline_ddl_white_list_ = index_schema.get_table_state_flag() != TABLE_STATE_NORMAL;
|
||||
int64_t ddl_rpc_timeout = 0;
|
||||
int64_t table_id = index_schema.get_table_id();
|
||||
|
||||
DEBUG_SYNC(BEFORE_UPDATE_GLOBAL_INDEX_STATUS);
|
||||
if (OB_FAIL(root_service_->get_common_rpc_proxy().to(GCTX.self_addr()).timeout(ObDDLUtil::get_ddl_rpc_timeout()).update_index_status(arg))) {
|
||||
if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(tenant_id_, table_id, ddl_rpc_timeout))) {
|
||||
LOG_WARN("get ddl rpc timeout fail", K(ret));
|
||||
} else if (OB_FAIL(root_service_->get_common_rpc_proxy().to(GCTX.self_addr()).timeout(ddl_rpc_timeout).update_index_status(arg))) {
|
||||
LOG_WARN("update index status failed", K(ret), K(arg));
|
||||
} else {
|
||||
LOG_INFO("notify index status changed finish", K(new_status), K(index_table_id_));
|
||||
|
@ -453,6 +453,8 @@ int ObModifyAutoincTask::wait_trans_end()
|
||||
int ObModifyAutoincTask::set_schema_available()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t tablet_count = 0;
|
||||
int64_t rpc_timeout = 0;
|
||||
ObRootService *root_service = GCTX.root_service_;
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
@ -463,7 +465,9 @@ int ObModifyAutoincTask::set_schema_available()
|
||||
} else {
|
||||
ObSArray<uint64_t> unused_ids;
|
||||
alter_table_arg_.ddl_task_type_ = share::UPDATE_AUTOINC_SCHEMA;
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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).
|
||||
execute_ddl_task(alter_table_arg_, unused_ids))) {
|
||||
LOG_WARN("alter table failed", K(ret));
|
||||
}
|
||||
|
@ -404,9 +404,15 @@ int ObTableRedefinitionTask::copy_table_indexes()
|
||||
LOG_INFO("indexes schema are already built", K(index_ids));
|
||||
} else {
|
||||
// if there is no indexes in new tables, we need to rebuild indexes in new table
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
int64_t ddl_rpc_timeout = 0;
|
||||
int64_t all_tablet_count = 0;
|
||||
if (OB_FAIL(get_orig_all_index_tablet_count(schema_guard, all_tablet_count))) {
|
||||
LOG_WARN("get all tablet count failed", K(ret));
|
||||
} else if (OB_FAIL(ObDDLUtil::get_ddl_rpc_timeout(all_tablet_count, ddl_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(ddl_rpc_timeout).
|
||||
execute_ddl_task(alter_table_arg_, index_ids))) {
|
||||
LOG_WARN("rebuild hidden table index failed", K(ret));
|
||||
LOG_WARN("rebuild hidden table index failed", K(ret), K(ddl_rpc_timeout));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -515,9 +521,12 @@ 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_;
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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));
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ddl_rpc_timeout).
|
||||
execute_ddl_task(alter_table_arg_, constraint_ids))) {
|
||||
LOG_WARN("rebuild hidden table constraint failed", K(ret));
|
||||
LOG_WARN("rebuild hidden table constraint failed", K(ret), K(ddl_rpc_timeout));
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("constraint has already been built");
|
||||
@ -583,9 +592,12 @@ 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_;
|
||||
if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
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));
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ddl_rpc_timeout).
|
||||
execute_ddl_task(alter_table_arg_, fk_ids))) {
|
||||
LOG_WARN("rebuild hidden table constraint failed", K(ret));
|
||||
LOG_WARN("rebuild hidden table constraint failed", K(ret), K(ddl_rpc_timeout));
|
||||
}
|
||||
}
|
||||
DEBUG_SYNC(TABLE_REDEFINITION_COPY_TABLE_FOREIGN_KEYS);
|
||||
@ -694,6 +706,7 @@ int ObTableRedefinitionTask::take_effect(const ObDDLTaskStatus next_task_status)
|
||||
DEBUG_SYNC(BEFORE_TABLE_REDEFINITION_TASK_EFFECT);
|
||||
#endif
|
||||
ObSArray<uint64_t> objs;
|
||||
int64_t ddl_rpc_timeout = 0;
|
||||
alter_table_arg_.ddl_task_type_ = share::MAKE_DDL_TAKE_EFFECT_TASK;
|
||||
alter_table_arg_.table_id_ = object_id_;
|
||||
alter_table_arg_.hidden_table_id_ = target_object_id_;
|
||||
@ -737,7 +750,9 @@ int ObTableRedefinitionTask::take_effect(const ObDDLTaskStatus next_task_status)
|
||||
}
|
||||
} else if (OB_FAIL(sync_stats_info())) {
|
||||
LOG_WARN("fail to sync stats info", K(ret), K(object_id_), K(target_object_id_));
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ObDDLUtil::get_ddl_rpc_timeout()).
|
||||
} else 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));
|
||||
} else if (OB_FAIL(root_service->get_ddl_service().get_common_rpc()->to(obrpc::ObRpcProxy::myaddr_).timeout(ddl_rpc_timeout).
|
||||
execute_ddl_task(alter_table_arg_, objs))) {
|
||||
LOG_WARN("fail to swap original and hidden table state", K(ret));
|
||||
if (OB_TIMEOUT == ret) {
|
||||
|
@ -249,6 +249,31 @@ int ObDDLUtil::get_tablets(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLUtil::get_tablet_count(const uint64_t tenant_id,
|
||||
const int64_t table_id,
|
||||
int64_t &tablet_count)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
tablet_count = 0;
|
||||
share::schema::ObSchemaGetterGuard schema_guard;
|
||||
const share::schema::ObTableSchema *table_schema = nullptr;
|
||||
if (OB_INVALID_ID == tenant_id || OB_INVALID_ID == table_id) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid arguments", K(ret), K(tenant_id), K(table_id));
|
||||
} else if (OB_FAIL(share::schema::ObMultiVersionSchemaService::get_instance().get_tenant_schema_guard(
|
||||
tenant_id, schema_guard))) {
|
||||
LOG_WARN("get tenant schema guard failed", K(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(schema_guard.get_table_schema(tenant_id, table_id, table_schema))) {
|
||||
LOG_WARN("get table schema failed", K(ret), K(tenant_id), K(table_id));
|
||||
} else if (OB_ISNULL(table_schema)) {
|
||||
ret = OB_TABLE_NOT_EXIST;
|
||||
LOG_WARN("get table schema failed", K(ret), K(table_id));
|
||||
} else {
|
||||
tablet_count = table_schema->get_all_part_num();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLUtil::refresh_alter_table_arg(
|
||||
const uint64_t tenant_id,
|
||||
const int64_t orig_table_id,
|
||||
@ -956,11 +981,60 @@ int ObDDLUtil::check_table_exist(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObDDLUtil::get_ddl_rpc_timeout()
|
||||
int ObDDLUtil::get_ddl_rpc_timeout(const int64_t tablet_count, int64_t &ddl_rpc_timeout_us)
|
||||
{
|
||||
return max(GCONF.rpc_timeout, 9 * 1000 * 1000L);
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t rpc_timeout_upper = 20L * 60L * 1000L * 1000L; // upper 20 minutes
|
||||
const int64_t cost_per_tablet = 20L * 60L * 100L; // 10000 tablets use 20 minutes, so 1 tablet use 20 * 60 * 100 us
|
||||
ddl_rpc_timeout_us = tablet_count * cost_per_tablet;
|
||||
ddl_rpc_timeout_us = max(ddl_rpc_timeout_us, 9 * 1000 * 1000L);
|
||||
ddl_rpc_timeout_us = min(ddl_rpc_timeout_us, rpc_timeout_upper);
|
||||
ddl_rpc_timeout_us = max(ddl_rpc_timeout_us, GCONF.rpc_timeout);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLUtil::get_ddl_rpc_timeout(const int64_t tenant_id, const int64_t table_id, int64_t &ddl_rpc_timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t tablet_count = 0;
|
||||
if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || OB_INVALID_ID == table_id)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(tenant_id), K(table_id));
|
||||
} else if (OB_FAIL(get_tablet_count(tenant_id, table_id, tablet_count))) {
|
||||
LOG_WARN("get tablet count failed", K(ret));
|
||||
} else if (OB_FAIL(get_ddl_rpc_timeout(tablet_count, ddl_rpc_timeout_us))) {
|
||||
LOG_WARN("get ddl rpc timeout failed", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ObDDLUtil::get_ddl_tx_timeout(const int64_t tablet_count, int64_t &ddl_tx_timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(get_ddl_rpc_timeout(tablet_count, ddl_tx_timeout_us))) {
|
||||
LOG_WARN("get ddl rpc timeout faild", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ObDDLUtil::get_ddl_tx_timeout(const int64_t tenant_id, const int64_t table_id, int64_t &ddl_tx_timeout_us)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(get_ddl_rpc_timeout(tenant_id, table_id, ddl_tx_timeout_us))) {
|
||||
LOG_WARN("get ddl rpc timeout faild", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t ObDDLUtil::get_default_ddl_rpc_timeout()
|
||||
{
|
||||
return min(20L * 60L * 1000L * 1000L, max(GCONF.rpc_timeout, 9 * 1000 * 1000L));
|
||||
}
|
||||
|
||||
int64_t ObDDLUtil::get_default_ddl_tx_timeout()
|
||||
{
|
||||
return get_default_ddl_rpc_timeout();
|
||||
}
|
||||
|
||||
|
||||
int ObDDLUtil::get_ddl_cluster_version(
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t task_id,
|
||||
|
@ -220,6 +220,10 @@ public:
|
||||
const int64_t table_id,
|
||||
common::ObIArray<common::ObTabletID> &tablet_ids);
|
||||
|
||||
static int get_tablet_count(const uint64_t tenant_id,
|
||||
const int64_t table_id,
|
||||
int64_t &tablet_count);
|
||||
|
||||
// get all tablets of a table by table_schema
|
||||
static int get_tablets(
|
||||
const share::schema::ObTableSchema &table_schema,
|
||||
@ -312,8 +316,12 @@ public:
|
||||
const uint64_t tenant_id,
|
||||
const uint64_t table_id,
|
||||
share::schema::ObSchemaGetterGuard &schema_guard);
|
||||
|
||||
static int64_t get_ddl_rpc_timeout();
|
||||
static int get_ddl_rpc_timeout(const int64_t tablet_count, int64_t &ddl_rpc_timeout_us);
|
||||
static int get_ddl_rpc_timeout(const int64_t tenant_id, const int64_t table_id, int64_t &ddl_rpc_timeout_us);
|
||||
static int get_ddl_tx_timeout(const int64_t tablet_count, int64_t &ddl_tx_timeout_us);
|
||||
static int get_ddl_tx_timeout(const int64_t tenant_id, const int64_t table_id, int64_t &ddl_tx_timeout_us);
|
||||
static int64_t get_default_ddl_rpc_timeout();
|
||||
static int64_t get_default_ddl_tx_timeout();
|
||||
|
||||
static int get_ddl_cluster_version(
|
||||
const uint64_t tenant_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user