[CP] executor 感知 create table if not exist do nothing

This commit is contained in:
fanfangzhou
2024-04-17 13:21:38 +00:00
committed by ob-robot
parent 67442e074b
commit 854a7a24df
4 changed files with 9 additions and 5 deletions

View File

@ -164,6 +164,7 @@ int ObCreateTableHelper::execute()
const ObTableSchema &table = arg_.schema_; const ObTableSchema &table = arg_.schema_;
//create table xx if not exist (...) //create table xx if not exist (...)
if (arg_.if_not_exist_) { if (arg_.if_not_exist_) {
res_.do_nothing_ = true;
ret = OB_SUCCESS; ret = OB_SUCCESS;
LOG_INFO("table is exist, no need to create again", LOG_INFO("table is exist, no need to create again",
"tenant_id", table.get_tenant_id(), "tenant_id", table.get_tenant_id(),

View File

@ -509,7 +509,8 @@ int ObSchemaUtils::try_check_parallel_ddl_schema_in_sync(
const ObTimeoutCtx &ctx, const ObTimeoutCtx &ctx,
sql::ObSQLSessionInfo *session, sql::ObSQLSessionInfo *session,
const uint64_t tenant_id, const uint64_t tenant_id,
const int64_t schema_version) const int64_t schema_version,
const bool skip_consensus)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int64_t start_time = ObTimeUtility::current_time(); int64_t start_time = ObTimeUtility::current_time();
@ -547,7 +548,8 @@ int ObSchemaUtils::try_check_parallel_ddl_schema_in_sync(
&& consensus_schema_version >= schema_version) { && consensus_schema_version >= schema_version) {
break; break;
} else if (refreshed_schema_version >= schema_version } else if (refreshed_schema_version >= schema_version
&& ObTimeUtility::current_time() - start_time >= consensus_timeout) { && (skip_consensus
|| ObTimeUtility::current_time() - start_time >= consensus_timeout)) {
break; break;
} else { } else {
if (REACH_TIME_INTERVAL(1000 * 1000L)) { // 1s if (REACH_TIME_INTERVAL(1000 * 1000L)) { // 1s

View File

@ -186,7 +186,8 @@ public:
const ObTimeoutCtx &ctx, const ObTimeoutCtx &ctx,
sql::ObSQLSessionInfo *session, sql::ObSQLSessionInfo *session,
const uint64_t tenant_id, const uint64_t tenant_id,
const int64_t schema_version); const int64_t schema_version,
const bool skip_consensus);
private: private:
static int get_tenant_variable(schema::ObSchemaGetterGuard &schema_guard, static int get_tenant_variable(schema::ObSchemaGetterGuard &schema_guard,
uint64_t tenant_id, uint64_t tenant_id,

View File

@ -607,7 +607,7 @@ int ObCreateTableExecutor::execute(ObExecContext &ctx, ObCreateTableStmt &stmt)
} else { } else {
int64_t refresh_time = ObTimeUtility::current_time(); int64_t refresh_time = ObTimeUtility::current_time();
if (OB_FAIL(ObSchemaUtils::try_check_parallel_ddl_schema_in_sync( if (OB_FAIL(ObSchemaUtils::try_check_parallel_ddl_schema_in_sync(
ctx, my_session, tenant_id, res.schema_version_))) { ctx, my_session, tenant_id, res.schema_version_, res.do_nothing_ /*skip_consensus*/))) {
LOG_WARN("fail to check paralleld ddl schema in sync", KR(ret), K(res)); LOG_WARN("fail to check paralleld ddl schema in sync", KR(ret), K(res));
} }
int64_t end_time = ObTimeUtility::current_time(); int64_t end_time = ObTimeUtility::current_time();
@ -2119,7 +2119,7 @@ int ObTruncateTableExecutor::execute(ObExecContext &ctx, ObTruncateTableStmt &st
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("truncate invalid ddl_res", KR(ret), K(res)); LOG_WARN("truncate invalid ddl_res", KR(ret), K(res));
} else if (OB_FAIL(ObSchemaUtils::try_check_parallel_ddl_schema_in_sync( } else if (OB_FAIL(ObSchemaUtils::try_check_parallel_ddl_schema_in_sync(
ctx, my_session, tenant_id, res.task_id_))) { ctx, my_session, tenant_id, res.task_id_, false /*skip_consensus*/))) {
LOG_WARN("fail to check parallel ddl schema in sync", KR(ret), K(res)); LOG_WARN("fail to check parallel ddl schema in sync", KR(ret), K(res));
} }
int64_t end_time = ObTimeUtility::current_time(); int64_t end_time = ObTimeUtility::current_time();