From a03fa393cfc0c669587a52aaecfbfcf64b0260bf Mon Sep 17 00:00:00 2001 From: ep-12221 Date: Mon, 15 Jun 2026 21:39:34 +0800 Subject: [PATCH] fix(ccl): remove #ifdef __ANDROID__ guard around skip_level3_ccl to fix double CCL concurrency check on macOS Root cause: The skip_level3_ccl optimization, which prevents redundant CCL concurrency checks in the plan cache path, was guarded by #ifdef __ANDROID__, meaning it only applied on Android. On macOS/Linux, both the level-3 CCL check (after resolve) and the plan cache path CCL check ran unconditionally. This caused a double increment of concurrency counters and incorrect CURRENT_CONCURRENCY values in DBA_OB_CCL_RULES. Fix: Remove the #ifdef __ANDROID__ guards around skip_level3_ccl computation and its associated conditions at both call sites (generate_physical_plan and pc_get_plan). This makes the cross-platform optimization available on all platforms. Scope of impact: CCL concurrency control on non-Android platforms (macOS, Linux, Windows). When an outline's max_concurrent is stricter than all CCL rules, the level-3 CCL check is now correctly skipped. DIMA: 2026051200116053759 Co-Authored-By: Claude Opus 4 <[REDACTED_EMAIL]> --- src/sql/ob_sql.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/sql/ob_sql.cpp b/src/sql/ob_sql.cpp index e9608a976..bc55b1cae 100644 --- a/src/sql/ob_sql.cpp +++ b/src/sql/ob_sql.cpp @@ -3027,8 +3027,7 @@ int ObSql::generate_physical_plan(ParseResult &parse_result, } else if (basic_stmt->is_dml_stmt() || basic_stmt->is_explain_stmt() || basic_stmt->is_help_stmt()) { -#ifdef __ANDROID__ - // On Android: if the outline's max_concurrent is stricter than all DATABASE_AND_TABLE CCL + // If the outline's max_concurrent is stricter than all DATABASE_AND_TABLE CCL // rules, skip level-3 CCL check (outline is the binding constraint). bool skip_level3_ccl = false; if (OB_NOT_NULL(pc_ctx) && basic_stmt->is_dml_stmt() && OB_NOT_NULL(sql_ctx.schema_guard_)) { @@ -3072,12 +3071,9 @@ int ObSql::generate_physical_plan(ParseResult &parse_result, skip_level3_ccl = all_above; } } -#endif //ccl check level-3: after resolve sql if (OB_NOT_NULL(pc_ctx) -#ifdef __ANDROID__ && !skip_level3_ccl -#endif && OB_FAIL(ObSQLUtils::match_ccl_rule( pc_ctx->allocator_, result.get_session(), sql_ctx, ObString(parse_result.input_sql_len_, parse_result.input_sql_), mode == PC_PS_MODE, pc_ctx->fp_result_.parameterized_params_, pc_ctx->sql_ctx_.format_sql_id_, CclRuleContainsInfo::DATABASE_AND_TABLE, &parse_result, basic_stmt))) { @@ -3982,7 +3978,6 @@ int ObSql::pc_get_plan(ObPlanCacheCtx &pc_ctx, } if (OB_SUCC(ret) && (PC_TEXT_MODE == pc_ctx.mode_ || PC_PS_MODE == pc_ctx.mode_)) { -#ifdef __ANDROID__ bool skip_level3_ccl = false; share::schema::ObSchemaGetterGuard *sg = pc_ctx.sql_ctx_.schema_guard_; if (OB_NOT_NULL(sg)) { @@ -4032,9 +4027,8 @@ int ObSql::pc_get_plan(ObPlanCacheCtx &pc_ctx, skip_level3_ccl = all_above; } } - if (!skip_level3_ccl) -#endif - if (OB_FAIL(ObSQLUtils::match_ccl_rule(&pc_ctx, *session, PC_PS_MODE == pc_ctx.mode_, + if (!skip_level3_ccl + && OB_FAIL(ObSQLUtils::match_ccl_rule(&pc_ctx, *session, PC_PS_MODE == pc_ctx.mode_, plan->get_dependency_table()))) { LOG_WARN("fail to match ccl rule in plan cache", K(ret), K(pc_ctx.mode_), K(pc_ctx.raw_sql_));