[CP] Fix parallel create conflict problem

This commit is contained in:
tino247
2024-02-07 03:25:45 +00:00
committed by ob-robot
parent b18cca536f
commit be2fe9dfce
4 changed files with 12 additions and 3 deletions

View File

@ -130,6 +130,7 @@ public:
void destroy() { init_ = false; }
bool is_inited() const { return init_; }
void set_timeout(int64_t timeout) { timeout_ = timeout; }
int64_t get_timeout() const { return timeout_; }
void set_trace_time(const bool is_trace_time) { is_trace_time_ = is_trace_time; }
void set_ratelimit(const bool do_ratelimit) { do_ratelimit_ = do_ratelimit; }
void set_bg_flow(const int8_t is_bg_flow) { is_bg_flow_ = is_bg_flow;}

View File

@ -935,6 +935,12 @@ int ObCreateTableHelper::check_and_set_parent_table_id_()
K(parent_database_id), K(parent_table_name));
}
}
} else {
if (foreign_key_arg.is_parent_table_mock_) {
ret = OB_ERR_PARALLEL_DDL_CONFLICT;
LOG_WARN("parenet table already exist, should retry",
KR(ret), K_(tenant_id), K(parent_table_id), K(foreign_key_arg));
}
}
// parent_table_id will be OB_INVALID_ID in the following cases:
// 1. foreign key is self reference.

View File

@ -563,6 +563,7 @@ class ObString;
ACT(BEFORE_GET_CONFIG_VERSION_AND_TRANSFER_SCN,)\
ACT(LS_GC_BEFORE_OFFLINE,)\
ACT(BEFORE_FETCH_SIMPLE_TABLES,)\
ACT(BEFORE_SEND_PARALLEL_CREATE_TABLE,)\
ACT(BEFORE_DROP_TENANT,)\
ACT(MAX_DEBUG_SYNC_POINT,)

View File

@ -574,10 +574,11 @@ int ObCreateTableExecutor::execute(ObExecContext &ctx, ObCreateTableStmt &stmt)
LOG_WARN("rpc proxy create table failed", KR(ret), "dst", common_rpc_proxy->get_server());
}
} else {
DEBUG_SYNC(BEFORE_SEND_PARALLEL_CREATE_TABLE);
int64_t start_time = ObTimeUtility::current_time();
ObTimeoutCtx ctx;
if (OB_FAIL(ObShareUtil::set_default_timeout_ctx(ctx, GCONF._ob_ddl_timeout))) {
LOG_WARN("fail to set timeout ctx", KR(ret));
if (OB_FAIL(ctx.set_timeout(common_rpc_proxy->get_timeout()))) {
LOG_WARN("fail to set timeout ctx", K(ret));
} else if (OB_FAIL(common_rpc_proxy->parallel_create_table(create_table_arg, res))) {
LOG_WARN("rpc proxy create table failed", KR(ret), "dst", common_rpc_proxy->get_server());
} else {
@ -2227,7 +2228,7 @@ int ObTruncateTableExecutor::execute(ObExecContext &ctx, ObTruncateTableStmt &st
} else {
// new parallel truncate
ObTimeoutCtx ctx;
if (OB_FAIL(ObShareUtil::set_default_timeout_ctx(ctx, (static_cast<obrpc::ObRpcProxy*>(common_rpc_proxy))->timeout()))) {
if (OB_FAIL(ctx.set_timeout(common_rpc_proxy->get_timeout()))) {
LOG_WARN("fail to set timeout ctx", K(ret));
} else {
int64_t start_time = ObTimeUtility::current_time();