fix bug:failed to execute direct_load after truncating table

This commit is contained in:
Revendell
2023-01-29 16:20:23 +08:00
committed by ob-robot
parent d7d52691d0
commit 195ab500ab
5 changed files with 30 additions and 13 deletions

View File

@ -48,17 +48,19 @@ int ObTableLoadCoordinatorCtx::init(ObSQLSessionInfo *session_info,
} else if (idx_array.count() != ctx_->param_.column_count_) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid idx_array", KR(ret), K(idx_array.count()), K_(ctx_->param_.column_count));
} else if (OB_FAIL(redef_table_.init(ctx_, session_info))) {
LOG_WARN("failed to init ddl processor", KR(ret));
} else if (OB_FAIL(redef_table_.start())) {
LOG_WARN("failed to create hidden table", KR(ret));
} else if (OB_FAIL(target_schema_.init(ctx_->param_.tenant_id_, ctx_->param_.database_id_,
ctx_->param_.target_table_id_, allocator_))) {
LOG_WARN("fail to init table load schema", KR(ret), K(ctx_->param_.tenant_id_),
K(ctx_->param_.target_table_id_));
} else {
// init redef table
if (OB_FAIL(redef_table_.init(ctx_, session_info))) {
LOG_WARN("failed to init ddl processor", KR(ret));
} else if (OB_FAIL(redef_table_.start())) {
LOG_WARN("failed to create hidden table", KR(ret));
} else if (OB_FAIL(target_schema_.init(ctx_->param_.tenant_id_, ctx_->param_.database_id_,
ctx_->param_.target_table_id_, allocator_))) {
LOG_WARN("fail to init table load schema", KR(ret), K(ctx_->param_.tenant_id_),
K(ctx_->param_.target_table_id_));
}
// init idx array
if (OB_FAIL(idx_array_.assign(idx_array))) {
else if (OB_FAIL(idx_array_.assign(idx_array))) {
LOG_WARN("failed to assign idx array", KR(ret), K(idx_array));
}
// init partition_location_
@ -148,6 +150,7 @@ void ObTableLoadCoordinatorCtx::destroy()
trans_ctx_map_.reuse();
segment_ctx_map_.reset();
commited_trans_ctx_array_.reset();
redef_table_.reset();
}
int ObTableLoadCoordinatorCtx::generate_credential(uint64_t user_id)

View File

@ -73,7 +73,10 @@ int ObTableLoadPartitionLocation::fetch_ls_locations(uint64_t tenant_id,
if (OB_FAIL(ret)) {
} else if (OB_FAIL(ObTabletToLSTableOperator::batch_get_ls(*(GCTX.sql_proxy_),
tenant_id, tablet_ids_, ls_ids))) {
LOG_WARN("table_load_partition failed to batch get ls", K(ret), K(tenant_id));
if (OB_LIKELY(OB_ITEM_NOT_MATCH == ret)) {
ret = OB_SCHEMA_NOT_UPTODATE;
}
LOG_WARN("table_load_partition failed to batch get ls", KR(ret), K(tenant_id));
} else {
ObLSLocation location;
ObHashMap<ObLSID, ObAddr> ls_location_map;

View File

@ -29,6 +29,11 @@ ObTableLoadRedefTable::ObTableLoadRedefTable()
}
ObTableLoadRedefTable::~ObTableLoadRedefTable()
{
reset();
}
void ObTableLoadRedefTable::reset()
{
if (!is_finish_or_abort_called_) {
abort(); // 这个必须执行
@ -162,8 +167,13 @@ int ObTableLoadRedefTable::abort()
LOG_WARN("failed to abort redef table", KR(ret), K(abort_redef_table_arg));
} else if (OB_FAIL(ObDDLExecutorUtil::wait_ddl_finish(ctx_->param_.tenant_id_, ddl_task_id_,
*session_info_, common_rpc_proxy))) {
LOG_WARN("failed to wait ddl finish", KR(ret));
} else {
if (OB_CANCELED == ret) {
ret = OB_SUCCESS;
} else {
LOG_WARN("failed to wait ddl finish", KR(ret));
}
}
if (OB_SUCC(ret)) {
LOG_INFO("abort_redef_table success", KR(ret));
}
THIS_WORKER.set_timeout_ts(origin_timeout_ts);

View File

@ -21,6 +21,7 @@ class ObTableLoadRedefTable
public:
ObTableLoadRedefTable();
~ObTableLoadRedefTable();
void reset();
int init(ObTableLoadTableCtx *ctx, sql::ObSQLSessionInfo *session_info);
int start();
int finish();

View File

@ -125,7 +125,7 @@ int ObTabletToLSTableOperator::batch_get_ls(
}
}
if (OB_SUCC(ret) && OB_UNLIKELY(ls_ids.count() != tablet_ids.count())) {
ret = OB_NOT_SUPPORTED;
ret = OB_ITEM_NOT_MATCH;
LOG_WARN("count of ls_ids and tablet_ids do not match,"
" there may be duplicates or nonexistent values in tablet_ids",
KR(ret), "tablet_ids count", tablet_ids.count(), "ls_ids count", ls_ids.count(),