Repository navigation
fix: retry stale regular index hints across CNs - #28641
Conversation
e5a9038 to
c30779e
Compare
|
Unrelated CI blockers from MatrixOne ALL CI run 34491898016 (attempt 1):
|
afb5dad to
04b61e8
Compare
435e98d to
b264c48
Compare
b264c48 to
dd95a4d
Compare
dd95a4d to
2f7921e
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed 480add4 against main 23b20ea. One concrete validation-boundary regression remains.
[P2] Preserve missing-index validation for consumers that never run prePipelineInitializer. recordUnresolvedIndexHint now admits every non-prepared permanent-table SELECT with a lockable ObjRef, but the deferred 1176 is restored only by Compile.prePipelineInitializer. Ordinary EXPLAIN instead calls frontend.doExplainStmt -> buildPlanWithAuthorization -> writeExplainResult directly. With CREATE TABLE t(id INT PRIMARY KEY); EXPLAIN SELECT id FROM t FORCE INDEX(idx_missing);, planning now succeeds with an unresolved marker and EXPLAIN emits a base-table plan instead of the former 1176. No DDL race is needed.
CREATE VIEW has the same boundary issue: genViewTableDef binds/optimizes the inner SELECT, validates temporary tables/plugins, then extracts columns and ViewSql; buildCreateView returns a DDL plan, not that marked Query. CREATE VIEW v AS SELECT id FROM t FORCE INDEX(idx_missing) can therefore persist an invalid definition without the new terminal check. A later SELECT from v then reaches the 1176. These are reachable consumers of the newly relaxed validation, not optional extra test preferences.
Please restrict deferral to an explicitly execution-owned/retry-capable planning context, or validate/retry unresolved hints at each non-executing consumer before returning EXPLAIN output or committing a view definition. Preserve immediate 1176 when no metadata-validation owner exists. Add both no-DDL-race negative cases. Also keep UnresolvedIndexHints in DeepCopyQuery: the manual copier currently omits the new correctness-bearing field, unlike protobuf round-trip; it should not disappear when a marked plan is copied.
Other closure review: planner canonicalization retains first-missing-name order; normal SELECT compilation includes parent metadata locking and returns the error before sources start, while Sirius rejects marked plans. Temporary/PREPARE/not-lock-meta cases remain immediate failures. The deterministic two-CN commit/rollback cases reuse the existing fixture and verify actual index use plus row visibility. The protobuf addition is additive and does not itself require sending an unresolved query to old CNs on the normal native path, because the coordinator must resolve/retry or fail before execution.
Evidence: current diff/producer/consumer source inspection and author-reported package, targeted multi-CN and race validation. I did not run native tests or independently execute the SQL counterexamples; findings are source-closed. No source modification or CI wait. Exact head/base rechecked before posting.
|
@XuPeng-SH — addressed your review in
Confirmed as a valid, in-scope regression: the new real-frontend tests reproduced successful text EXPLAIN and invalid CREATE VIEW publication before the correction. The new deep-copy assertion also failed before the change. The terminal check is now shared between native execution and the non-executing consumers: ordinary EXPLAIN (planner and frontend output paths), view definitions, and CTAS schema inference. Non-executing consumers return 1176 before output or catalog publication. Native SELECT keeps its existing metadata-lock/retry boundary. New tests cover ordinary/verbose/explicit-text EXPLAIN and CREATE VIEW with missing USE/FORCE/IGNORE/order-scoped hints, no catalog objects after rejected CREATE VIEW/CTAS, unchanged view results after rejected REPLACE/ALTER, valid hints, and copy mutation isolation. The existing deterministic regular-index writer commit/rollback and FULLTEXT cases are retained. Validation results are recorded in the updated PR description. Full planner, compiler, and frontend packages passed; the complete targeted integration test passed three times and passed three more times with planner/compiler/frontend coverage instrumentation (32.219s, 21.6% coverage). Incremental lint reported zero issues. No protected workflow/orchestration files or mo-tester changes. Re-requesting review; no merge performed. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the updated head. The prior blockers are closed: validation now covers EXPLAIN and persisted view/CTAS consumers, and DeepCopy preserves the marker without aliasing ObjectRefs. The stale-definition path either retries through the existing bounded transaction retry or returns 1176 before data-source execution; I found no remaining correctness or liveness blocker. Exact-head CI is green.
Merge Queue Status
This pull request spent 2 hours 18 minutes 27 seconds in the queue, including 53 minutes 45 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Related to #28639
What this PR does / why we need it:
A verifier CN can plan an index-hinted SELECT using a table definition from before a concurrent CREATE INDEX. Returning MySQL 1176 during planning prevents the compiler's existing metadata lock from detecting the committed definition change and rebuilding the statement.
The planner records unresolved permanent-table index hints and their parent table references in an additive query-plan field. SELECT compilation includes those references in the existing metadata-lock boundary. A definition change requests the existing statement retry; an index that remains absent returns 1176 before data sources start. Temporary tables, prepared statements, and metadata-unlocked scans retain immediate planner validation. Sirius rejects marked plans so offloading cannot bypass validation.
Plan consumers that never execute the query must also reject unresolved hints. One shared
ValidateUnresolvedIndexHintsfunction now owns the terminal error for execution, ordinary EXPLAIN (both planner and frontend output paths), view definitions, and CTAS schema inference. CREATE/REPLACE/ALTER VIEW cannot persist a marked inner query, and invalid CTAS fails before creating a table. EXPLAIN ANALYZE and physical-plan execution retain their existing executable-plan path.DeepCopyQuerypreserves the marker list and independently copies each parent object reference.The shared validator retains the CI follow-up's direct first-marker selection, preserving first-missing-name order without the staticcheck-invalid always-returning loop. This revision rebases the branch without conflicts onto
origin/mainate2580f993a5a742f562f3cfcd0f53ca89a9ee373; the protobuf source and generated binding are unchanged from the reviewed head.Issue-to-test proof
Validation
Local validation on the rebased correction (Darwin/arm64, Go 1.26.4; native tests use
.agents/skills/mo-dev/scripts/mo-cgo-test):./pkg/sql/plan ./pkg/sql/compile,-count=1 -timeout=10m: passed (16.246s / 7.334s)../pkg/frontend,-count=1 -timeout=15m: passed (39.360s)../pkg/tests/issues,-v -cover -count=3 -timeout=10m -run '^TestIssue27487ConcurrentInsertIsIncludedInNewIndex$': all three iterations passed (19.362s). This package has no production statements; actual kernel instrumentation is separately checked below.GOWORK=off golangci-lint run --concurrency 2 -c .golangci.yml --new-from-rev origin/main ./pkg/pb/plan ./pkg/sql/plan ./pkg/sql/compile ./pkg/frontend ./pkg/tests/issues: passed, 0 issues../pkg/tests/issues,-coverpkg=./pkg/sql/plan,./pkg/sql/compile,./pkg/frontend -count=3 -timeout=10m -run '^TestIssue27487ConcurrentInsertIsIncludedInNewIndex$': passed (32.219s; 21.6% coverage across the three instrumented packages).Earlier validation recorded for the reviewed head
480add48fe(not claimed as new-head runs):make generate-pb; native tests ofpkg/pb/plan,pkg/sql/plan, andpkg/sql/compile; the targeted multi-CN test in normal mode and with-race -count=2; fullpkg/sql/compilewith-race -count=1; CGo-configuredgo vetof the protobuf/compiler/planner/issues packages; compiler golangci-lint. CI run 34589843787 completed successfully, including Ubuntu UT, coverage, SCA, and both multi-CN BVT jobs.The SQL regression uses the existing authenticated embedded fixture and real MySQL frontend. It adds one one-row table and reuses the fixture; no additional service or mo-tester changes are needed. The deterministic stale-plan proof requires the in-process compiler barrier and held writer, so it remains in this integration suite rather than a separate external BVT script.
Residual risks
The protobuf field is additive. The coordinator resolves/retries or rejects unresolved execution plans before sources start; ordinary EXPLAIN and schema-only consumers retain immediate missing-key rejection. This does not introduce a global synchronous catalog-publication barrier or a new retry mechanism. Required CI and human review remain separate from local verification.