Repository navigation
perf(load): avoid per-batch locks for covered unique indexes - #27814
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Deep review result: blocking correctness finding. The new “full-domain” intent is not full-domain for FLOAT/DOUBLE unique keysThe new path in
MatrixOne supports non-finite FLOAT/DOUBLE values, and Therefore Concrete reachable case: create table t(id bigint primary key, u double unique);
-- LOAD DATA contains Inf/NaN for uAfter this PR the exact per-batch Exclusive hidden-index key lock is removed. An independent Exclusive row write to the hidden unique-index table for This is not hypothetical type reachability: FLOAT/DOUBLE unique indexes are accepted by DDL, non-finite values are explicitly supported, and there is no DML guard that makes an existing hidden table unaddressable by name. Please either:
Add deterministic coverage for FLOAT and DOUBLE What passed
The finite-key design and lifecycle handling look sound; the non-finite keyspace hole is the blocker. GitHub does not allow the PR author account to submit a formal |
|
Follow-up deep review decision: REQUEST_CHANGES-equivalent. GitHub does not allow the PR author account to submit a formal Request changes review, so this is posted as a blocking review comment. 1. Mandatory design-first gate is missingThis is no longer a focused implementation-only bug fix. Excluding tests, generated protobuf, deepcopy, and the proto declaration, it changes about 597 non-generated production lines and crosses planner → plan protobuf → compiler → lockservice. It also changes a distributed locking/concurrency protocol and a material LOAD hot path. Both the size trigger and multiple complexity triggers require a stable, versioned, approved design. The PR body is useful implementation documentation, but it is not a separately reviewed design revision and has no traceable design approval. The design must close at least:
Implementation approval remains blocked until that design is reviewed and approved. 2. The performance evidence does not demonstrate that #27775 is fixedThe reported indexed result improves from 16.107 s to 10.84 s, or 32.7%. However, the no-index control also improves from 7.732 s to 5.34 s, or 30.9%. Normalizing by that control, the indexed/no-index ratio changes only:
That is only about a 2.5% controlled improvement. It cannot substantiate recovery from the reported 2.2–2.4x indexed regression. The values are also single observations with no median/variance and use a different scale/topology from the 100M/1B reproducer. Eliminating three coarsening events is good mechanism evidence, but it is not endpoint evidence. Please provide repeated, alternating exact-main/exact-PR runs on the same host and state, report median and spread plus the indexed/no-index ratio, and validate at a size that crosses the regression threshold, preferably the existing 100M case before the 1B case. 3. The changed public LOAD + FK contract has no committed BVT regressionThis PR reroutes FK-related LOAD from the legacy planner to the modern path and changes SQL-visible transaction waiting, commit/rollback visibility, and FK failure behavior. Planner UTs, real-lockservice UTs, and the manual 55-transaction matrix are valuable, but none is a persistent frontend/public-SQL regression. The current BVT corpus has LOAD and FK cases, but no case exercises LOAD DATA with FK concurrency as one scenario. Add a minimal deterministic multi-session BVT covering parent commit and rollback while a child LOAD waits, with durable row/error oracles and no sleep-based synchronization. Keep scale/performance in the big-data suite. Verified in this pass
The implementation direction is plausible, and I found no new concrete FLOAT boundary, leak, or internal all-new lock-order defect. The three evidence/design gates above still block approval. |
|
Design-first revision v1 is now available at docs/design/load_data_unique_index_locking.md. The design intentionally narrows this PR back to #27775:
This removes the availability regression where a long child LOAD would block all parent writes, including disjoint keys, and avoids an unnecessary mixed-version plan contract. Implementation remains blocked pending traceable approval of design revision v1. Requesting one planner/compile owner and one lockservice owner to review the invariants, alternatives, rollout/rollback, and 100M/1B acceptance gate. |
|
Design revision v3 is pushed at 44d0d92 and supersedes v1 plus the current production implementation. The PR body now reflects the actual pending state and all known correctness, cache, retry-amplification, HLC-wait, availability, type-domain, and performance risks.\n\n@aunjgr @aptend @fengttt @iamlinjunhong: please review the exact design commit. Implementation remains blocked until one SQL planner/compile owner and one lockservice owner explicitly approve that revision. In particular, please challenge (1) the post-acquisition HLC/logtail freshness proof, (2) the one-fence-per-Run sticky rebuild fallback, (3) large-LOAD cache exclusion, and (4) direct hidden-writer availability/deadlock impact. |
|
Deep review result on exact head GitHub does not allow the PR author account to submit a formal Request changes review, so this is posted as a blocking review comment. 1. The delivered production code is the superseded implementation, not design v3This is a concrete correctness blocker, not only a process marker. The current head still:
That is precisely the v1/v2 behavior which the v3 document rejects. The already-reproduced counterexample remains reachable in the actual code: The design text identifies this as unsafe, but documentation at the last commit does not repair the production path in the preceding commits. The PR must not merge until the superseded implementation is removed and replaced by the exact approved design. 2. The mandatory design gate is still openDesign revision v3 is substantially better scoped than the prior revisions. I traced the main proof chain against current code:
I found no additional contradiction in that abstract v3 proof. However, the two required owner decisions have not been recorded: SQL planner/compile must approve the physical-generation/retry/cache contract, and lockservice must approve the HLC/unlock/owner-rebind proof plus the broader direct-hidden-writer wait/deadlock surface. Those are material ownership and availability decisions and cannot be inferred from green CI. 3. Required implementation and endpoint evidence is absentThe latest CI is green only for the obsolete implementation. It does not exercise the v3 classifier, deferred freshness helper, coordinator fence, exact retry proof, cache isolation, owner restart/rebind, idle heartbeat progress, sticky rebuild fallback, or the complete negative eligibility matrix. The performance claim is also still open. The existing 5M numbers improve the normalized indexed/no-index ratio by only about 2.5%; they prove mechanism movement, not recovery of #27775. The design correctly requires alternating exact-main/exact-PR 100M runs and a normalized >=30% improvement before merge. That evidence must be produced from the final implementation, not reused from this head. Unhappy-path verdict
Reviewed range: merge-base |
|
Additional deep-review finding on unchanged head The previous production-code blocker remains open. This comment does not repeat it; it challenges a new assumption inside the proposed v3 contract.
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Multi-angle deep review on exact head 44d0d92292: REQUEST_CHANGES-equivalent.
GitHub does not allow the PR author account to submit a formal Request changes review. This review therefore records the same blocking decision as a COMMENTED review. It consolidates the current disposition; the two concrete blockers are documented in detail at the implementation review and the Q2/client-close review.
Correctness and delivered artifact
The code at this head is still the superseded v1/v2 implementation, while the PR body explicitly says it must not be reviewed or merged as the intended implementation. It still changes planner/FK routing and the plan wire shape, mutates canonical lock targets, and uses ordinary LockTableWithMode without the v3 post-acquisition HLC/logtail fence, strict snapshot proof, exact retry generation, 1 GiB admission gate, or sticky fallback.
Consequently, the already-proven no-active-conflict stale-snapshot execution remains reachable in the delivered code: a direct hidden-table writer can commit after LOAD's snapshot and before its full lock; the table-lock path has bat=nil, performs no key-version scan, and the LOAD can start duplicate discovery from the stale snapshot. This alone blocks merge.
Design v3: safety, retry, and cache
I re-traced the complete v3 proof across planner output, compiler retry lifecycle, transaction snapshot semantics, remote mirror admission, lockservice ownership, CN logtail frontier, and TN heartbeat publication.
Under its stated assumptions, the core safety sequence is coherent: acquire base and all promoted hidden ownership first; construct a coordinator HLC strict upper bound; wait until the applied frontier reaches it; install a strictly later RC snapshot; physically rebuild; and admit source initialization only with an exact transaction/target/fence/generation proof. Transaction-owned locks survive RollbackLastStatement, and remote NewWithSnapshot waits for its local logtail through SnapshotTS.Prev(). I found no third independent safety counterexample in that abstract sequence.
However, v3 is not yet approvable because one of its required liveness assumptions is false in the current API: TxnOperator.UpdateSnapshot(ctx, fence) calls updateSnapshot(..., nil), so TxnClient.Close cannot reach the waiter's close channel. With a live caller context and stalled logtail, the fence wait can remain blocked while holding txnOperator.mu. The exact close-only deterministic regression required by v3 would fail. The design must select a real close-aware ownership boundary before implementation.
The cache/retry policy is appropriately fail-closed in principle, but none of it exists in this head. Final validation must prove canonical-plan immutability, no proof inheritance across prepared/session-cache or logical rebuilds, exactly one optimization fence per Compile.Run, and fresh physical/remote source state after retry.
Concurrency, deadlock, and unhappy paths
The proposed full-domain hidden ownership intentionally broadens conflicts for direct physical-index writers and can introduce new wait/deadlock edges. For ordinary eligible DML, base-before-hidden ordering can prevent the common inversion, but earlier-statement retained locks and direct multi-table physical clients remain real residual cycles. This is an availability tradeoff requiring traceable lockservice-owner approval plus deterministic commit/rollback/cancel/timeout/deadlock tests; green CI on the obsolete implementation is not that evidence.
Q1/Q3 are plausibly bounded in v3: compiler proof state is schema-sized, no input-sized retained collection or new goroutine is required, and partial lock prefixes stay transaction-owned. Q2 is not closed because of the client-close disconnect above. Failure after source initialization also retains the new hidden full locks in explicit transactions until terminal commit/rollback; that documented behavior needs regression coverage because it broadens writer impact.
Performance and operational evidence
The mechanism hypothesis is credible—removing per-batch UNIQUE lock encoding/submission should eliminate lock-budget coarsening—but issue #27775 is an endpoint regression, and the endpoint is still unproven. The existing 5M result improves the normalized indexed/no-index ratio by only about 2.5%, far below v3's >=30% acceptance gate. There is still no alternating exact-main/exact-final-head 100M evidence, no 1B confirmation, and no final-head accounting for fence wait, two compile generations, retry count, lock waits/deadlocks, coarsening, profiles, or log volume.
The final evidence must also come from the implementation that will merge. The current all-green CI validates only the old unsafe code and cannot be carried forward as v3 evidence.
Compatibility and merge state
V3's intended no-protobuf/no-FK-routing scope is the right compatibility direction, but the delivered branch still contains the opposite changes and must remove them. The PR is also BEHIND latest main (fcc8ff3b03). There is currently no changed-file overlap with the intervening main commits, but the final implementation must rebase before exact-head correctness and scale validation so evidence is not attached to a stale base.
Decision
Do not merge or approve this head. Required closure:
- obtain traceable SQL planner/compile-owner and lockservice-owner approval for one exact design revision;
- repair the close-aware fence-wait contract and add its deterministic race/cancellation tests;
- replace, rather than layer on, the superseded production implementation;
- rebase latest main and run the full v3 negative/unhappy/concurrency matrix; and
- pass the exact-final-head 100M normalized performance gate and 1B confirmation.
Reviewed range: base 7bb89155a2, head 44d0d92292; git diff --check passes. CI was inspected but intentionally not treated as evidence for code that has not been implemented.
|
Design revision v4 is ready for owner review on exact head The superseded production implementation has been removed; the PR diff is now design-only. V4 closes the Q2 blocker found in v3: the compiler no longer relies on @aunjgr @aptend @fengttt @iamlinjunhong: please record explicit approval or concrete blockers on this exact revision. Production implementation remains blocked until one SQL planner/compile owner and one lockservice owner approve it. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Multi-angle deep review on exact head 47c3f1e748b9dffbf12ef4864905741660f309bf against base fb56746be170fa7e51191853f9e9f5a518ef69e0: REQUEST_CHANGES-equivalent.
GitHub does not allow the PR author account to submit a formal Request changes review, so this is submitted as a blocking COMMENTED review.
V4 closes the concrete v3 client-close defect. I traced the proposed HLC upper-bound fence, TN heartbeat -> ordered empty progress -> CN minimum apply frontier, exact transaction-generation revalidation, metadata-lock collection through MULTI_UPDATE.UpdateCtxList, current LOAD byte estimate, and admitted integer/composite range endpoints against current main. I did not find a new counterexample in that core abstract freshness proof. Three design issues still need to be resolved before owner approval and implementation.
1. [P1 availability/scope] Do not optimize explicit multi-statement transactions without a demonstrated need
The eligibility contract admits every pessimistic RC transaction, including BEGIN ... LOAD DATA ... and autocommit=0. The document then has to accept all of the following new surface:
- a stalled future-logtail fence while the transaction already owns base plus promoted hidden full-domain Exclusive locks;
- cancellation/fence/source/rebuild failure retaining those hidden locks until a later explicit
COMMITorROLLBACK; - prior-statement physical locks forming a new cross-statement cycle; and
- snapshot/retry/workspace correctness for earlier statements.
These are reachable SQL states, not theoretical impossibilities, but they are not required by #27775's single-statement large-LOAD workload. Current code already exposes an exact, stable discriminator through txnOp.TxnOptions().Autocommit and .ByBegin (the ALTER path uses byBegin || !autocommit to identify an explicit transaction).
Please make statement-owned autocommit a positive eligibility invariant: Autocommit == true && ByBegin == false. Add negative classifier tests for both BEGIN and autocommit=0. If explicit transactions are intentionally required, the design instead needs concrete workload evidence that justifies the added surface and an approved terminal policy for a stalled/failed fence after full ownership; documenting indefinite retained ownership is not enough for this issue's narrow fix.
2. [P2 design] The proposed large-LOAD planner cache mutation duplicates current behavior
The cache argument in sections 6.1/10.15 does not match exact current code for the only admitted modern shape:
- an eligible modern LOAD contains
MULTI_UPDATE; - physical compilation already executes
node.NotCacheable = truefor everyMULTI_UPDATE(pkg/sql/compile/compile.go:2045-2060); and - frontend session-cache insertion calls
checkNodeCanCacheonly after execution/compile (pkg/frontend/mysql_cmd_executor.go:5922-5929).
Therefore a direct modern LOAD plan is already excluded from the session cache, independent of input size. planGenerationReused remains the correct fail-closed guard for legacy/reused session or prepared generations. The proposed planner-time 1 GiB NotCacheable helper/constant synchronization adds code and tests without closing a reachable cache path.
Please remove this planner change from the design, or identify and test one concrete admitted path that can currently insert the modern MULTI_UPDATE LOAD plan into the session cache before compilation marks it. Keep the 1 GiB estimate solely as the compiler's fixed-cost admission gate unless evidence shows otherwise.
3. [P2 validation/observability] The mandatory fence-cost gate has no safe measurement contract
Section 11 requires the HLC-fence wait duration to be reported separately, while section 12 promises no new metric label. The v4 client-owned path cannot simply reuse txnOperator.doCostAction(UpdateSnapshotEvent, locked=false): that helper takes txnOperator.mu.RLock across the supplied action, recreating the exact lock-held-during-logtail-wait defect that v4 removes. TxnClient.WaitLogTailAppliedAt itself currently exposes no duration metric.
Specify the implementation-level observation point now: capture immutable transaction/event identity under the short pre-wait lock, time only WaitLogTailAppliedAt with no lifecycle/operator lock held, then publish one bounded-cardinality existing event or metric after the wait. It must distinguish fence wait from physical recompile, record success/cancel/client-close, and add no per-heartbeat/per-target/per-batch log. Add a deterministic assertion that the event is emitted exactly once per attempted fence and that close/cancel does not leak a waiter or duplicate the event.
Q1-Q3 and other angles
| Dimension | Exact-head verdict |
|---|---|
| Correctness/linearization | Core v4 proof is coherent against current one-primary-TN/logtail behavior; no new stale-snapshot counterexample found. |
| Q1 ownership | Compiler target/proof state is schema-bounded; lock ownership remains transaction/lockservice-owned; v4 generation token prevents stale waiter mutation. |
| Q2 waits/lifecycle | Client close/notify/restart ordering is now coherent, but explicit-transaction admission unnecessarily preserves the largest retained-lock and cross-statement wait graph. |
| Q3 boundedness | At most one fence/retry and schema-bounded slices are sound; no input-sized retained state or new goroutine is proposed. |
| Performance | Cost model is plausible, but the 100M normalized >=30% endpoint gate is still open and the fence duration is not yet safely observable. |
| Compatibility | No wire/on-disk change; optional client capability fails closed. The shared clock-helper refactor still needs exact equivalence tests. |
| Logging | No direct log-storm site is proposed; existing wait/deadlock diagnostics still require the scale gate. |
The PR is intentionally docs-only and still has no SQL planner/compile-owner or lockservice-owner approval, final implementation, exact-main/final-head 100M evidence, or 1B confirmation. Green CI on this head cannot close those gates. git diff --check is clean; code tests are not counted because the exact diff is one design document.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Multi-angle self-review on exact design head 93e53055633ff0eb13d8917a6abca330c7260ce2 against latest base fb56746be170fa7e51191853f9e9f5a518ef69e0: the three v4 blockers are resolved; no additional self-found design blocker remains in v5.
This is not an approval or merge recommendation. The mandatory design gate still requires explicit approval from one SQL planner/compile owner and one lockservice owner, and production implementation plus 100M/1B endpoint evidence are intentionally absent.
Resolved findings
- Scope/availability: first-attempt eligibility now positively requires
TxnOptions.Autocommit == true && ByBegin == false.BEGIN(which may retainAutocommit=true) andautocommit=0are explicit negative controls. Terminal acquisition/fence/retry/source/commit failures go through the existing single-statement whole-txn rollback, so promoted hidden full locks cannot survive into a later user statement. Cross-statement workspace and retained-lock cycles are removed from the admitted graph. - Cache design: the proposed planner-time >=1 GiB
NotCacheablemutation and shared planner/compiler helper are deleted. Exact current compile already setsNotCacheableon every reachableMULTI_UPDATE, and frontend checks cacheability after compile. The 1 GiB estimate is compiler-only;planGenerationReusedfails closed for reused legacy/session/prepared generations. - Observability/liveness: the fence path explicitly forbids
txnOperator.doCostAction, because it would holdop.mu.RLockacrossWaitLogTailAppliedAt. The client times only that wait with no lifecycle/active-shard/operator lock or event callback held and emits through one post-unlock epilogue. One dedicated histogram has four pre-bound outcomes and 21 fixed 0.1 ms-to-~105 s buckets plus+Inf; each attempted wait emits exactly once, pre-wait rejection emits none, and no dynamic identity or log is added.
Q1-Q3 / design verdict
| Dimension | V5 result |
|---|---|
| Safety | Core order remains metadata -> base -> all promoted hidden ownership -> strict coordinator HLC upper-bound -> close-aware applied-frontier wait/install -> exact physical retry proof -> source initialization. No new counterexample found. |
| Q1 ownership | Compiler slices/proof are schema-bounded and cleared by their root owner; locks remain transaction/lockservice-owned and release exactly once through autocommit commit/rollback; metric timing retains no txn/event identity. |
| Q2 liveness | Physical waits terminate through holder release/context/timeout/deadlock. Fence wait observes frontier progress, context/deadline, and client close with no lifecycle/operator lock held. Commit/rollback/restart are not wake sources but are not blocked by the waiter; defensive generation validation rejects stale installation. |
| Q3 boundedness | At most one optimization fence/retry and one metric observation per Compile.Run; no new goroutine/log/input-sized state; metric cardinality and buckets are fixed. |
| Compatibility | No planner policy, protobuf/wire, catalog, durable, lock-mode, FK-routing, or generic table-range change. Mixed CN versions contend in the same existing physical lock namespace. |
| Performance | Per-batch promoted UNIQUE lock work becomes schema-fixed, but every eligible LOAD pays one future-fence wait and physical recompile. The compiler-only >=1 GiB gate and mandatory normalized 100M/1B gate remain necessary. |
| Test architecture | V5 maps BEGIN/autocommit-off negatives, whole-autocommit rollback, exact-one metric outcomes, close/cancel races, owner rebind/restart, range endpoints, retry proof, and scale evidence to deterministic UT/integration/performance layers. No sleeps or large data are assigned to UT/BVT. |
Evidence and limits
- Complete v4->v5 diff and every affected contract/table entry reviewed.
- Source facts rechecked at exact base: transaction options and frontend terminal branches;
MULTI_UPDATENotCacheablemutation before frontend cache publication;doCostActionread-lock lifetime; close-aware timestamp waiter cleanup. git diff --checkand Markdown fence balance pass; worktree is clean after commit.- Branch is 0 commits behind latest
main; onlydocs/design/load_data_unique_index_locking.mddiffers. - No Go/BVT run is claimed for this docs-only revision. Current CI can validate delivery hygiene but cannot validate the absent implementation.
@aunjgr @aptend @fengttt @iamlinjunhong: please review exact v5 commit 93e5305563, especially the HLC/unlock proof, physical retry generation contract, direct-hidden-writer availability tradeoff, statement-owned eligibility, and bounded fence metric.
|
V6 convergence revision is pushed at exact commit The repeated review loop was process and mechanism debt, not one last missing conditional: earlier revisions skipped the unproven #26706 causal boundary, repaired serial counterexamples while retaining future-HLC fencing, and let the PR body/issue/design describe different states. V6 now:
The stale #27775 comment that called this the root cause/final fix has been corrected. This head remains docs-only and must not merge as the fix. Production code is blocked on the causal gate and explicit approval of this exact revision by one SQL planner/compile owner and one lockservice owner. @aunjgr @aptend @fengttt @iamlinjunhong please return the complete blocker set against this exact revision, especially the commit->unlock->barrier ordering, physical retry/source rebuild proof, one-budget timeout semantics, and direct hidden-writer availability tradeoff. |
|
Implementation and multi-angle self-review were completed on Key review findings fixed before push:
Validation passed: full This is still not an approval/merge claim. The exact #26706 causal A/B, final 100M/1B normalized endpoint evidence, SQL/compile-owner review, and lockservice-owner review remain mandatory. The PR intentionally remains Draft. |
|
SCA failure on exact head Root cause: the two newly added test files contained only the first half of the Apache-2.0 header and omitted the warranty/limitations paragraph:
The patch changes comments only. Local execution of the same CI command passed terminally: No production/test behavior changed, so the exact-head UT/race/vet evidence remains semantically valid. New CI has been triggered; not waiting for it here. |
|
V8 convergence review completed on exact head The final code blocker found in v7 is fixed: one aggregate promotion context previously existed, but each Deterministic closure added on the same head:
Validation passed: affected normal packages, full owning-package race, both focused real-lockservice tests under measured Q1-Q3: locks remain transaction/lockservice-owned; cancellation does not double-unlock; every new wait is context/deadline bounded; retained state is schema-bounded; no production log/goroutine/channel or dynamic-cardinality metric was added. The ordinary lock path gained no options-struct growth or wrapper around The PR body now records the complete review-loop root cause, every resolved design/correctness issue, exact validation, and all residual risks. I found no additional deterministic code blocker in this pass. This is not a merge/issue-closure claim. Exact #26706 causal A/B, final-head 100M/1B normalized endpoint evidence, and fresh approval from one SQL/compile owner plus one lockservice owner remain mandatory independent gates. @aunjgr @aptend @iamlinjunhong please review exact v8 head |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Fixes #27775
Important
Draft status on exact head
f48843c9e2, rebased onmain07fe9a69c6: deterministic implementation/code closure is complete. The causal A/B, 100M/1B endpoint evidence, and exact-head SQL/compile plus lockservice owner approvals are still required. Do not merge or call #27775 fixed from local tests.Design:
docs/design/load_data_unique_index_locking.md, revision v8.Problem and evidence boundary
The reported 100M/1B indexed
LOAD DATAregression correlates with hidden-UNIQUE per-batch lock encoding/submission, lock coarsening, higher mutex delay, and lower CPU utilization. The no-index control is comparatively stable.This is still a hypothesis, not proven causality. The exact #26706 parent/merge A/B (
6742f958d466vs35db232dfc3b) has not been run. The earlier 5M experiment changed the normalized indexed/no-index ratio by only about 2.5%, so it is mechanism evidence, not proof that #27775 is fixed. Implementation was explicitly requested before that external gate; the PR therefore remains Draft.Current v8 design and implementation
Only a positively identified large modern
LOAD DATAcan qualify:Autocommit=true,ByBegin=false);Cost*Rowsize >= 1 GiB, uncompressed CSV/JSONLINE remote source;engine.LogtailReadBarriercapability;Missing, contradictory, duplicated, unsupported, reused, or ambiguous state fails closed to exact
mainbehavior. FLOAT/DOUBLE remain ineligible because the current finite table-range endpoints do not cover infinities and every NaN payload. Real production shapes such as auint32base PK and binary-varcharcomposite hidden PK are admitted.The canonical logical plan is never mutated. Before source initialization, generation zero:
The retry validates an exact coordinator-local proof: transaction ID, logical plan identity, physical generation, installed snapshot, frontier, and target value. It filters only covered hidden row targets from a local
LockOpcopy. Logical rebuild, reused generation, capability/protocol mismatch, or proof mismatch permanently disables the optimization for thatCompile.Run.No protobuf/wire/catalog/durable-state change, planner cache policy, generic lock ordering, goroutine, channel, or production log site is introduced.
Correctness and unhappy-path closure
min(lock_wait_timeout, 120s, caller deadline).varcharfull-range test proves an interior Exclusive writer waits, the fenced retry is reentrant with no second barrier, and transaction rollback lets the writer proceed.BEGIN,autocommit=0, SI, optimistic, mirror, aborted, and missing-ID transactions.Lifecycle audit:
Performance and operational risk
The intended complexity change is:
Safeguards:
doLockcallers pass a zero scalar deadline; noLockOptionsgrowth, wrapper call around the existing non-inlined lock function, allocation, goroutine, log, or retained state was added;time.Now()is not evaluated when neither the existing session timeout nor the promotion deadline is present;These checks bound implementation overhead only. Eligible LOAD still holds base and hidden domains through barrier, retry, execution, and commit, and pays one barrier plus recompile. Exact-main/final-head endpoint runs must decide whether that tradeoff is worthwhile.
Why review kept finding new blockers, and what changed
The repeated
Request changesloop was a review-process failure, not one endlessly recurring defect:V8 separates three gates: deterministic code closure, causal/endpoint evidence, and owner acceptance. A missing code oracle requires code/test change; pending scale evidence or approval does not. Conversely, local green tests are not promoted into causal proof.
Concrete issues found and resolved or explicitly removed from scope:
Exact-head local validation
On
f48843c9e2/ base07fe9a69c6:./pkg/sql/compile,./pkg/sql/colexec/lockop,./pkg/util/metric/v2;B=30s,N=100and passed for both real-lockservice success/reentry and cancellation/deadline/prefix-release tests;go vetpassed for all three affected packages;license-eye header check: 5906 checked, 4840 valid, 0 invalid, 1066 ignored;license-eye dep checkpassed;git diff --checkpassed.The isolated macOS worktree reused unchanged, platform-matched CGo and third-party artifacts from the primary checkout for these tests; no CGo source changes are in this PR. The reusable platform/provenance guard is submitted separately as #27852.
Remaining merge gates and residual risks
mainand exact final head for at least three successful 100M runs per indexed shape plus no-index control; require >=80% recovery of the normalized regression gap and <=15% no-index median regression, then one 1B confirmation.fengtttapproval is on the pre-v8 head and does not close this gate.