Fix auto-commit of rebuild hidden table index
This commit is contained in:
@ -224,7 +224,7 @@ int ObColumnRedefinitionTask::copy_table_indexes()
|
||||
int64_t active_task_cnt = 0;
|
||||
// check if has rebuild index
|
||||
if (has_rebuild_index_) {
|
||||
} else if (OB_FAIL(ObDDLTaskRecordOperator::get_create_index_task_cnt(GCTX.root_service_->get_sql_proxy(), tenant_id_, object_id_, active_task_cnt))) {
|
||||
} else if (OB_FAIL(ObDDLTaskRecordOperator::get_create_index_task_cnt(GCTX.root_service_->get_sql_proxy(), tenant_id_, target_object_id_, active_task_cnt))) {
|
||||
LOG_WARN("failed to check index task cnt", K(ret));
|
||||
} else if (active_task_cnt >= MAX_ACTIVE_TASK_CNT) {
|
||||
ret = OB_EAGAIN;
|
||||
|
||||
@ -443,7 +443,7 @@ int ObTableRedefinitionTask::copy_table_indexes()
|
||||
int64_t active_task_cnt = 0;
|
||||
// check if has rebuild index
|
||||
if (has_rebuild_index_) {
|
||||
} else if (OB_FAIL(ObDDLTaskRecordOperator::get_create_index_task_cnt(GCTX.root_service_->get_sql_proxy(), tenant_id_, object_id_, active_task_cnt))) {
|
||||
} else if (OB_FAIL(ObDDLTaskRecordOperator::get_create_index_task_cnt(GCTX.root_service_->get_sql_proxy(), dst_tenant_id_, target_object_id_, active_task_cnt))) {
|
||||
LOG_WARN("failed to check index task cnt", K(ret));
|
||||
} else if (active_task_cnt >= MAX_ACTIVE_TASK_CNT) {
|
||||
ret = OB_EAGAIN;
|
||||
|
||||
@ -15407,7 +15407,7 @@ int ObDDLService::reconstruct_index_schema(obrpc::ObAlterTableArg &alter_table_a
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLService::rebuild_hidden_table_index_in_trans(
|
||||
int ObDDLService::rebuild_hidden_table_index(
|
||||
const uint64_t tenant_id,
|
||||
ObSchemaGetterGuard &schema_guard,
|
||||
ObDDLOperator &ddl_operator,
|
||||
@ -15452,18 +15452,11 @@ int ObDDLService::rebuild_hidden_table_index_in_trans(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trans.is_started()) {
|
||||
int temp_ret = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (temp_ret = trans.end(OB_SUCC(ret)))) {
|
||||
LOG_WARN("trans end failed", "is_commit", OB_SUCCESS == ret, K(temp_ret));
|
||||
ret = (OB_SUCC(ret)) ? temp_ret : ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLService::rebuild_hidden_table_index(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
int ObDDLService::rebuild_hidden_table_index_in_trans(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
ObSArray<uint64_t> &index_ids)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -15541,12 +15534,19 @@ int ObDDLService::rebuild_hidden_table_index(obrpc::ObAlterTableArg &alter_table
|
||||
new_table_schemas,
|
||||
index_ids))) {
|
||||
LOG_WARN("failed to add new index schema", K(ret));
|
||||
} else if (OB_FAIL(rebuild_hidden_table_index_in_trans(dst_tenant_id,
|
||||
} else if (OB_FAIL(rebuild_hidden_table_index(dst_tenant_id,
|
||||
*dst_tenant_schema_guard,
|
||||
ddl_operator,
|
||||
trans,
|
||||
new_table_schemas))) {
|
||||
LOG_WARN("failed to rebuild hidden table index in trans", K(ret));
|
||||
LOG_WARN("failed to rebuild hidden table index", K(ret));
|
||||
}
|
||||
}
|
||||
if (trans.is_started()) {
|
||||
int temp_ret = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (temp_ret = trans.end(OB_SUCC(ret)))) {
|
||||
LOG_WARN("trans end failed", "is_commit", OB_SUCCESS == ret, K(temp_ret));
|
||||
ret = (OB_SUCC(ret)) ? temp_ret : ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15694,7 +15694,7 @@ int ObDDLService::check_and_get_rebuild_constraints(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLService::rebuild_hidden_table_constraints_in_trans(
|
||||
int ObDDLService::rebuild_hidden_table_constraints(
|
||||
const ObAlterTableArg &alter_table_arg,
|
||||
const ObTableSchema &orig_table_schema,
|
||||
const ObTableSchema &hidden_table_schema,
|
||||
@ -15747,17 +15747,10 @@ int ObDDLService::rebuild_hidden_table_constraints_in_trans(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trans.is_started()) {
|
||||
int temp_ret = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (temp_ret = trans.end(OB_SUCC(ret)))) {
|
||||
LOG_WARN("trans end failed", "is_commit", OB_SUCCESS == ret, K(temp_ret));
|
||||
ret = (OB_SUCC(ret)) ? temp_ret : ret;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLService::rebuild_hidden_table_constraints(ObAlterTableArg &alter_table_arg,
|
||||
int ObDDLService::rebuild_hidden_table_constraints_in_trans(ObAlterTableArg &alter_table_arg,
|
||||
ObSArray<uint64_t> &cst_ids)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -15792,12 +15785,19 @@ int ObDDLService::rebuild_hidden_table_constraints(ObAlterTableArg &alter_table_
|
||||
orig_table_schema,
|
||||
hidden_table_schema))) {
|
||||
LOG_WARN("failed to get orig and hidden table schema", K(ret));
|
||||
} else if (OB_FAIL(rebuild_hidden_table_constraints_in_trans(alter_table_arg,
|
||||
} else if (OB_FAIL(rebuild_hidden_table_constraints(alter_table_arg,
|
||||
*orig_table_schema,
|
||||
*hidden_table_schema,
|
||||
trans,
|
||||
cst_ids))) {
|
||||
LOG_WARN("failed to rebuild hidden table constraints in trans", K(ret));
|
||||
LOG_WARN("failed to rebuild hidden table constraints", K(ret));
|
||||
}
|
||||
if (trans.is_started()) {
|
||||
int temp_ret = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (temp_ret = trans.end(OB_SUCC(ret)))) {
|
||||
LOG_WARN("trans end failed", "is_commit", OB_SUCCESS == ret, K(temp_ret));
|
||||
ret = (OB_SUCC(ret)) ? temp_ret : ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
@ -16124,7 +16124,7 @@ int ObDDLService::get_rebuild_foreign_key_infos(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLService::rebuild_hidden_table_foreign_key_in_trans(
|
||||
int ObDDLService::rebuild_hidden_table_foreign_key(
|
||||
ObAlterTableArg &alter_table_arg,
|
||||
const ObTableSchema &orig_table_schema,
|
||||
const ObTableSchema &hidden_table_schema,
|
||||
@ -16279,7 +16279,7 @@ int ObDDLService::rebuild_hidden_table_foreign_key_in_trans(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDDLService::rebuild_hidden_table_foreign_key(ObAlterTableArg &alter_table_arg,
|
||||
int ObDDLService::rebuild_hidden_table_foreign_key_in_trans(ObAlterTableArg &alter_table_arg,
|
||||
ObSArray<uint64_t> &cst_ids)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -16314,14 +16314,14 @@ int ObDDLService::rebuild_hidden_table_foreign_key(ObAlterTableArg &alter_table_
|
||||
orig_table_schema,
|
||||
hidden_table_schema))) {
|
||||
LOG_WARN("failed to get orig and hidden table schema", K(ret));
|
||||
} else if (OB_FAIL(rebuild_hidden_table_foreign_key_in_trans(alter_table_arg,
|
||||
} else if (OB_FAIL(rebuild_hidden_table_foreign_key(alter_table_arg,
|
||||
*orig_table_schema,
|
||||
*hidden_table_schema,
|
||||
false/*rebuild_child_table_fk*/,
|
||||
*dst_tenant_schema_guard,
|
||||
trans,
|
||||
cst_ids))) {
|
||||
LOG_WARN("failed to rebuild hidden table foreign key in trans", K(ret));
|
||||
LOG_WARN("failed to rebuild hidden table foreign key", K(ret));
|
||||
}
|
||||
if (trans.is_started()) {
|
||||
int temp_ret = OB_SUCCESS;
|
||||
@ -16642,7 +16642,7 @@ int ObDDLService::swap_orig_and_hidden_table_state(obrpc::ObAlterTableArg &alter
|
||||
} else if (OB_FAIL(drop_child_table_fk(alter_table_arg, new_orig_table_schema,
|
||||
*hidden_table_schema, schema_guard, trans))) {
|
||||
LOG_WARN("failed to drop origin table fk", K(ret));
|
||||
} else if (OB_FAIL(rebuild_hidden_table_foreign_key_in_trans(alter_table_arg,
|
||||
} else if (OB_FAIL(rebuild_hidden_table_foreign_key(alter_table_arg,
|
||||
*orig_table_schema, *hidden_table_schema, true/*rebuild_child_table_fk*/, schema_guard, trans, fk_cst_ids))) {
|
||||
LOG_WARN("failed to rebuild hidden table fk", K(ret));
|
||||
} else if (OB_FAIL(check_hidden_table_constraint_exist(hidden_table_schema,
|
||||
@ -33077,7 +33077,7 @@ int ObDDLSQLTransaction::end(const bool commit)
|
||||
} else if (OB_ISNULL(schema_service_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("schema service is null", K(ret));
|
||||
} else if (enable_check_ddl_epoch_ && OB_FAIL(lock_ddl_epoch(this))) {
|
||||
} else if (commit && enable_check_ddl_epoch_ && OB_FAIL(lock_ddl_epoch(this))) {
|
||||
// compare ddl_epoch promise execute on master
|
||||
LOG_WARN("lock_ddl_epoch fail", K(ret));
|
||||
} else if (commit && need_end_signal_) {
|
||||
|
||||
@ -543,7 +543,7 @@ public:
|
||||
* @param [in] alter_table_arg
|
||||
* @param [out] cst_ids: new foreign key id
|
||||
*/
|
||||
int rebuild_hidden_table_foreign_key(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
int rebuild_hidden_table_foreign_key_in_trans(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
common::ObSArray<uint64_t> &cst_ids);
|
||||
/**
|
||||
* This function is called by the storage layer in the second stage of offline ddl
|
||||
@ -553,7 +553,7 @@ public:
|
||||
* @param [in] alter_table_arg
|
||||
* @param [out] cst_ids: new constraint id
|
||||
*/
|
||||
int rebuild_hidden_table_constraints(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
int rebuild_hidden_table_constraints_in_trans(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
common::ObSArray<uint64_t> &cst_ids);
|
||||
/**
|
||||
* This function is called by the storage layer in the second stage of offline ddl
|
||||
@ -565,7 +565,7 @@ public:
|
||||
* @param [in] frozen_version
|
||||
* @param [out] index_ids: new index table id
|
||||
*/
|
||||
int rebuild_hidden_table_index(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
int rebuild_hidden_table_index_in_trans(obrpc::ObAlterTableArg &alter_table_arg,
|
||||
common::ObSArray<uint64_t> &index_ids);
|
||||
/**
|
||||
* This function is called by the storage layer in the fourth stage of offline ddl
|
||||
@ -1533,7 +1533,7 @@ private:
|
||||
const ObTableSchema &orig_table_schema,
|
||||
const bool rebuild_child_table_fk,
|
||||
ObArray<ObForeignKeyInfo> &rebuild_fk_infos);
|
||||
int rebuild_hidden_table_foreign_key_in_trans(
|
||||
int rebuild_hidden_table_foreign_key(
|
||||
obrpc::ObAlterTableArg &alter_table_arg,
|
||||
const share::schema::ObTableSchema &orig_table_schema,
|
||||
const share::schema::ObTableSchema &hidden_table_schema,
|
||||
@ -1563,13 +1563,13 @@ private:
|
||||
const ObTableSchema &orig_table_schema,
|
||||
const ObTableSchema &new_table_schema,
|
||||
ObIArray<ObConstraint> &rebuild_constraints);
|
||||
int rebuild_hidden_table_constraints_in_trans(
|
||||
int rebuild_hidden_table_constraints(
|
||||
const obrpc::ObAlterTableArg &alter_table_arg,
|
||||
const share::schema::ObTableSchema &orig_table_schema,
|
||||
const share::schema::ObTableSchema &hidden_table_schema,
|
||||
common::ObMySQLTransaction &trans,
|
||||
common::ObSArray<uint64_t> &cst_ids);
|
||||
int rebuild_hidden_table_index_in_trans(
|
||||
int rebuild_hidden_table_index(
|
||||
const uint64_t tenant_id,
|
||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||
ObDDLOperator &ddl_operator,
|
||||
|
||||
@ -3818,23 +3818,23 @@ int ObRootService::execute_ddl_task(const obrpc::ObAlterTableArg &arg,
|
||||
} else {
|
||||
switch (arg.ddl_task_type_) {
|
||||
case share::REBUILD_INDEX_TASK: {
|
||||
if (OB_FAIL(ddl_service_.rebuild_hidden_table_index(
|
||||
if (OB_FAIL(ddl_service_.rebuild_hidden_table_index_in_trans(
|
||||
const_cast<obrpc::ObAlterTableArg &>(arg), obj_ids))) {
|
||||
LOG_WARN("failed to rebuild hidden table index", K(ret));
|
||||
LOG_WARN("failed to rebuild hidden table index in trans", K(ret));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case share::REBUILD_CONSTRAINT_TASK: {
|
||||
if (OB_FAIL(ddl_service_.rebuild_hidden_table_constraints(
|
||||
if (OB_FAIL(ddl_service_.rebuild_hidden_table_constraints_in_trans(
|
||||
const_cast<obrpc::ObAlterTableArg &>(arg), obj_ids))) {
|
||||
LOG_WARN("failed to rebuild hidden table constraints", K(ret));
|
||||
LOG_WARN("failed to rebuild hidden table constraints in trans", K(ret));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case share::REBUILD_FOREIGN_KEY_TASK: {
|
||||
if (OB_FAIL(ddl_service_.rebuild_hidden_table_foreign_key(
|
||||
if (OB_FAIL(ddl_service_.rebuild_hidden_table_foreign_key_in_trans(
|
||||
const_cast<obrpc::ObAlterTableArg &>(arg), obj_ids))) {
|
||||
LOG_WARN("failed to rebuild hidden table foreign key", K(ret));
|
||||
LOG_WARN("failed to rebuild hidden table foreign key in trans", K(ret));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user