fix: preserve clone auto-increment continuation - #27154
Conversation
4a1a0e6 to
34cfec2
Compare
|
One unrelated CI blocker remains pending fresh CI on rebased head
The aggregate Coverage failure was derivative: its direct log records Failed jobs from workflow attempt 1 were rerun exactly once. Attempt 2 remained active when the required branch rewrite superseded its head and will not be rerun again. #27771 remains resolved as a blocker for this PR. Merged PR #27772 remains in the current base. The required conflict-free rebase onto |
8a326a5 to
9cf7087
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 9cf7087.
The fresh-clone versus ALTER-copy allocator ownership split is consistent: visible columns on a new table are rebuilt from the transaction-consistent copied-row maximum plus schema/session floors, while retained-ID ALTER paths and hidden internal allocators preserve their fenced state. I also verified the issue reproduction against a locally built exact-head server (source next 4, clone insert 4, clone next 5), explicit AUTO_INCREMENT=100, and the clone-of-clone empty-source counterexample. Focused checked-allocator tests, the full table_clone package, and focused race tests passed. No blocking code issue found.
9cf7087 to
6ad3ad6
Compare
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27092
What this PR does / why we need it:
Root cause
Fresh table clones copied the source row from
mo_catalog.mo_increment_columnsinto the destination allocator. That row'soffsetis the upper bound of a reserved allocation batch (10,000 in the reproducer), not the source session's next visible value (4). Because a fresh clone has a new table ID and an independent allocator, transferring that reservation made its first generated ID 10,001.The persisted table definition separately carries explicit schema lower bounds such as
ALTER TABLE ... AUTO_INCREMENT = 100. Those are user-visible state and must still be preserved.Changes
AUTO_INCREMENT, explicit transactions, and historical snapshots.Issue-to-test proof
4, clone next5, and first cloned-table insert4for table, database, and both Data Branch clone forms.1; a source whose largest row was deleted seeds the independent clone from the copied maximum; explicitAUTO_INCREMENT = 100inserts100; snapshot clone asserts snapshot-visible rows plus exact4 / 5inserted/next values.10and11, then assigns12to the first destination insert.40001through40006, without introducing a new 10,000-value gap at each clone.Verification
Latest semantic rebase: base
0d7f4dd69ac86a2d8e8746af568a7de8aaa4287a/ heada9f360b768c09d2682fc960812306f1c7595cc94was rebased ontomainat117714dd98de39aadc1e55e49f584dba58c51a10, producing exact headbc71e21cdf903b0dc2c3a9331c79ef847988db11.git range-diff 0d7f4dd69a..a9f360b768 origin/main..HEAD: all four patches are equivalent.ff530dfc6cb58fd343bc0663b95c917a95aa40fc.git diff --check origin/main..HEAD: passed; final diff remains exactly the intended six clone files.-v, and-count=1: all eight focused clone allocator tests plus incomingTestDedupLoadCleansUpAfterPanic,TestDedupLoadWaiterGetsSuccessfulOwnerValue, andTestDedupLoadCleansUpAfterLoadCancelpassed on exact headbc71e21cdf. Each incoming concurrency test also passed independently under-race -count=100after adaptive measurement selected the 100-run cap.pkg/sql/compileandpkg/sql/colexec/table_clonepackages passed on patch-equivalent prior head93146ffceb; the two later base increments change only fileservice and objectio tests, so that package evidence remains semantically valid. The changed fileservice regression passed on heada9f360b768, and the three changed objectio tests passed in normal and focused race modes on headbc71e21cdf.ObjectRefownership, metadata locking, nor their fixtures, so those topology/BVT results remain semantically valid.pkg/sql/compile,pkg/sql/colexec/table_clone,pkg/frontend,pkg/sql/plan,pkg/vm/engine, andpkg/vm/engine/disttaepackages passed.pkg/common/morpcpackage passed on the prior patch-equivalent head; the current base change does not touch MORPC inputs.TestIssue27294PreparedNumericOverloadsexecution test, and the MORPC deadline-contract test. The relevant full compile, table-clone, planner, table-function, IVFFLAT, frontend, and MORPC packages passed.33192377421attempt 1 on superseded patch-equivalent heada9f360b768passed all three changed clone BVT files (65/65,74/74, and163/163). Attempt 2 was still active when the required branch rewrite superseded that head. Fresh CI is required for the new base.The incoming base adds ten merged changes after the prior reviewed base, with no overlap in this PR's six files:
edcc672d64(Fix prepared fulltext score threshold; push prepared distance bounds #27765) carries prepared FULLTEXT score guards and prepared IVFFLAT distance bounds. Its NULL/reuse, literal/parameter parity, per-row-expression, plan-shape, and engine guard regressions passed locally; the full planner, table-function, and IVFFLAT packages passed.52e307962f(fix(compile): preserve in-memory rows on single remote scans #27796) changes single-remote scan reader ownership insidepkg/sql/compile. Both new reader-selection regressions, the eight clone allocator tests, and the full compile/table-clone packages passed together, proving the remote scan path does not alter clone allocator ownership.8b6a44e83c(fix: accept fractional prepared numeric overloads #27556) adds sparse prepared-numeric plan metadata and runtime category rebinding. Its focused planner/frontend and real execute-path regressions passed; the full planner/frontend/compile packages passed.90534b6c61(fix(morpc): normalize expired deadline errors #27711) normalizes expired MORPC deadlines while preserving explicit cancellation. Its focused deadline contract and full MORPC package passed.67ac89c058(test: cover multi-insert prepare and privileges #27741) adds four multi-insert PREPARE/privilege BVT assets only. It changes no production or clone input. Its exact merged-base BVT evidence remains valid.4cbdc2cf46(fix(frontend): publish ANALYZE stats by table generation #27758) makes ANALYZE stats publication table-generation-aware and adds scoped cancellation/admission ownership. Its 39 focused regressions and the affected full packages passed with this PR's clone tests. This PR changes no stats lifecycle state or ANALYZE BVT input.2e1be09278(test(morpc): isolate factory timeout budget #27812) isolates a MORPC factory-timeout regression from queue-admission and process-wide worker timing. It changes test code only; the exact test and full MORPC package passed on the patch-equivalent combined head.52336df805(fix: preserve insert metadata lock during index creation #27792) preserves the INSERT write target's metadata lock by deep-copying scan-localObjectRefvalues. Its focused alias-isolation UT passed together with this PR's eight clone tests, and the full compile/table-clone packages passed. This PR does not touch INSERT plans or metadata lock ownership.0d7f4dd69a(test(fileservice): remove async callback flush deadline #27789) removes an async callback flush deadline from one fileservice lifecycle test and adds a direct pending-queue assertion. It changes test code only; the exact regression passed on heada9f360b768.117714dd98(test(objectio): synchronize dedupLoad waiter admission #27782) replaces scheduler sleeps in three objectiodedupLoadwaiter tests with a bounded admission barrier. It changes test code only. All three changed tests passed with the eight clone allocator tests on headbc71e21cdf; each also passed independently under-race -count=100.The incoming FULLTEXT/IVFFLAT, multi-insert, ANALYZE, concurrent-index, and pessimistic DDL public-path results remain exact merged-base evidence because this PR changes none of their planner/index/stats/lock execution inputs or case files. Fresh CI will independently exercise the combined head.
CI investigation
bc71e21cdf. Its latest evidence belongs to superseded patch-equivalent heada9f360b768.33192377421attempt 1 reproduced the same root cause in PROXY BVT.snapshot/sys_restore_system_table_to_sys_account.sqlcompleted 313 statements with 311 successful and exactly two failed. Itsmo_stored_procedurecomparisons at SQL rows 167 and 183 expected ignoredproc_idvalues1920000/1920001, received ignored values9/10, and mo-tester cross-pairedtest_if_hit_second_elseifwithtest_if_hit_elseatrow:0,column:1.clone_auto_increment_state.sql65/65,table_clone.sql74/74, andtemporary_table_clone.sql163/163. Same-head Ubuntu UT, shared build, SCA, coverage UT, and PESSIMISTIC BVT passed.prerequisites_ready: falsefor generation33192377421-1and exits before coverage processing.constructTableClone; the failing case contains no clone or Data Branch path and has identical base/head blob20efac5d8d440ef3a86e459d0d0553c921c2e398. No PR code change was made. Repeated exact-head evidence is recorded on [Bug]: mo-tester sorts rows by ignored columns, causing false BVT failures #27164.33192377421attempt 1 were rerun exactly once. Attempt 2 remained active when the required branch rewrite superseded its head and will not be rerun again.Residual risks
A fresh clone intentionally owns an independent allocator. If the source's highest generated rows were deleted, the clone starts after the highest row it actually copied rather than inheriting a source CN's unused cached range. Explicit schema lower bounds remain preserved. There are no catalog, wire-format, or API changes in this PR, and the fix does not read or mutate source CN allocator caches.