Repository navigation
fix: preserve sequences in database clone and restore - #27401
Conversation
2cde2d1 to
b66d61a
Compare
b66d61a to
daaf727
Compare
b2a42d0 to
6a61422
Compare
|
@XuPeng-SH The quota mismatch was valid and is addressed in 6a61422.
Regression proof: The branch is rebased onto current |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 6a614227bbbd2cfc6923da6a16294596ca0d5f9e against base 0e5db4ce1d0eafdc06923b80bbb740f1205566ba.
Both prior blockers are closed:
- restore now resolves the current destination
relkindand drops the matching sequence/table/view before recreating the historical sequence; - DATA BRANCH quota now excludes receipt-less sequences, matching both
cloneReceiptcreation and persistedmo_branch_metadatausage. The regression matrix covers empty, mixed, sequence-only, view-only, and ordinary-only sources.
The rebase-only commits are patch-equivalent to the previously reviewed stack (git range-diff), with the quota fix as the sole semantic addition. Q1-Q3 found no new resource, wait, or unbounded-growth edge in that predicate-only change.
Validation on this exact head:
go list,go build, andgo vetfor./pkg/frontendpass;- focused sequence restore, entry-point, clone rewrite, transaction, and branch quota tests pass;
- full
go test ./pkg/frontend -count=1passes; git diff --checkis clean and all 26 latest checks are completed with allowed conclusions.
No blocking findings remain.
Merge Queue Status
This pull request spent 46 minutes 48 seconds in the queue, including 46 minutes 16 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Related to #27049
What this PR does / why we need it:
Root cause
Database clone and restore source collection unconditionally filtered out
relkind = 'S'. Views were still restored, so a sequence-backed view survived while its sequence did not.Sequences also cannot use the ordinary table-clone path: their catalog DDL may contain the latest
ALTER SEQUENCE, and their current value /is_calledstate lives in the sequence relation row. In addition, nested backgroundCREATE/DROP SEQUENCEpreviously finished the enclosing transaction early, which would make Data Branch fail and leave partial clone state on a later error.The initial sequence restore path also assumed that a current same-named object was a sequence.
DROP SEQUENCE IF EXISTSintentionally does nothing for a table or view, so a historical sequence restore collided atCREATE SEQUENCEafter a valid sequence→table/view generation change.After sequences entered the shared source list, DATA BRANCH preflight quota counting treated them as receipt-backed tables even though sequence restore deliberately creates no
mo_branch_metadatareceipt. The preflight increment therefore exceeded the persisted quota usage.Changes
CREATE SEQUENCESQL from the historical column type and sequence definition at the selected timestamp, including signed/unsigned types, increment, bounds, start, and cycle mode.last_seq_numandis_calledare preserved exactly.relkindand execute exactly one matchingDROP TABLE,DROP VIEW, orDROP SEQUENCE; an absent object needs no drop, while inconsistent duplicate metadata fails explicitly.Issue-to-test proof
clone_database_sequence.sqldirectly proves #27049 by asserting:relkind = 'S';TestSequenceRestoreEntryPointsexecutes the same-account snapshot, PITR, and cross-account snapshot sequence branches and asserts the exact relkind-specific drop and restore statements. It directly proves snapshot sequence→table, PITR sequence→view, cross-account sequence→sequence, and missing-account behavior.TestGetCreateSequenceSQLErrorsproves type/state query failures, missing historical metadata, and invalid cycle state are returned rather than silently constructing bad DDL. The extendedTestRestoreSequenceStatecovers absent/current/ambiguous destination metadata plus lookup, drop, create, delete, and historical-state-copy failures, proving each path stops at the exact failed operation.TestCloneDatabaseSourceBranchTableCountproves the DATA BRANCH quota increment uses the same unit as persisted receipts: a mixed ordinary-table/sequence/view source counts as one, sequence-only/view-only/empty sources count as zero, and ordinary tables continue to count individually.Tests run
.agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -count=1 -timeout=120s -run 'Test(SequenceRestoreMetadataAndOrdering|RestoreSequenceState|SequenceRestoreEntryPoints)$' ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s -run 'Test(GetCreateSequenceSQLErrors|RestoreSequenceState)$' ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -count=1 -timeout=240s ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=15m ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s -run '^(TestGetFkDepsFromTableInfos|TestSequenceRestoreMetadataAndOrdering|TestRestoreSequenceState|TestRewriteCloneSequenceCreateSQL)$' ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s -run '^Test_statement_type$' ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s -run '^TestBranchDeleteDatabaseTableIDsSQLReusesCloneObjectFilter$' ./pkg/frontendmo-tester ... -m run -r 100 -i clone_database_sequence -g— 108/108 passed; the pre-rebase change was also stable across 3/3 runsmo-tester ... -m run -n -r 100 -i clone_sequence,clone_can_rollback -g— 88/88 passedGOWORK=off go list -mod=readonly ./pkg/frontendGOWORK=off ... go vet -mod=readonly ./pkg/frontendmake buildGOWORK=off go build -mod=readonly ./pkg/frontendGOWORK=off go vet -mod=readonly ./pkg/frontend.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s -run '^(TestRestoreSequenceState|TestSequenceRestoreEntryPoints)$' ./pkg/frontend— all 12 subtests passed.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/frontend— passedCGO_CFLAGS=... CGO_LDFLAGS=... GOWORK=off go vet -mod=readonly ./pkg/frontend— passedmake buildafter rebasing ontoorigin/main— passedmo-tester ... -m genrs -i clone_database_sequence, followed by manual semantic inspection of every new resultmo-tester ... -i clone_database_sequence -r 100— 131/131 passed.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s -run '^TestCloneDatabaseSourceBranchTableCount$' ./pkg/frontend— passed all empty, sequence-only, view-only, mixed, and ordinary-table cases.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/frontend— passed after the quota correctionCGO_CFLAGS=... CGO_LDFLAGS=... GOWORK=off go build -mod=readonly ./pkg/frontend— passedCGO_CFLAGS=... CGO_LDFLAGS=... GOWORK=off go vet -mod=readonly ./pkg/frontend— passedResidual risk
There is no storage-format or wire-protocol change. Clone/restore adds three catalog reads and up to four transactional restore statements per sequence; this is bounded by the number of sequence objects and is outside query hot paths. Table-level
CREATE TABLE ... CLONE sequenceremains rejected as a non-base-table source.