Repository navigation
Description
Problem
The new unit test TestTruncateLifecycleRCWaitPolicy in pkg/sql/compile fails in a clean checkout of MatrixOne base commit 7391899db5073f33765341641daacecb95f02ab7 (test added by #29827). This is a verified test/CI failure; the reproduction does not establish a production TRUNCATE defect.
Reproduction
Run from the repository root:
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run '^TestTruncateLifecycleRCWaitPolicy$' ./pkg/sql/compileThe command was run on both the PR follow-up tree at 86950324dee35fdd92f23404a780c2354252932b and a detached, clean checkout of 7391899db5073f33765341641daacecb95f02ab7. The clean checkout used the same provenance-validated native CGo inputs.
Expected behavior
All three subtests should enter the lifecycle admission lock and finish according to their release, cancellation, or retained-owner case.
Actual behavior
On the clean base, all three subtests time out after about 33 seconds. They fail with TRUNCATE did not request lifecycle admission; the mock trace also reports an unexpected Snapshot call and does not satisfy the expected HasLockTable(41) call. The same failure occurs on the PR source tree. The full pkg/sql/compile suite consequently fails.
The latest observed origin/main is 02a2823c2007d5e4fb4ada148e93743df337551a; it contains the same test body. The exact failing test was independently reproduced on base 7391899db, not executed on 02a2823c.
Environment
- macOS arm64, Go 1.27.1
- CGo test wrapper:
.agents/skills/mo-dev/scripts/mo-cgo-test - Base:
7391899db5073f33765341641daacecb95f02ab7 - PR source checked:
86950324dee35fdd92f23404a780c2354252932b - Test introduced in test(sql): cover truncate lifecycle waits and cancellation #29827; the merged change records prior successful validation, including repeated runs under race.
Acceptance criteria
- Determine whether the failure is caused by test setup/mock expectations or by lifecycle admission behavior.
- Make the focused test pass on current main and under its intended repeated/race validation.
- Preserve the tested semantics: fresh owners wait, cancellation removes wait bookkeeping, and retained-owner promotion follows the documented FastFail behavior.
- Avoid weakening the assertions merely to make the test green.
Evidence and related links
- Test source:
matrixone/pkg/sql/compile/ddl_test.go
Lines 3573 to 3678 in 7391899
func TestTruncateLifecycleRCWaitPolicy(t *testing.T) { for _, tc := range []struct { name string retained bool cancel bool }{ {name: "fresh owner waits"}, {name: "fresh wait can be canceled", cancel: true}, {name: "retained owner fails promotion", retained: true}, } { t.Run(tc.name, func(t *testing.T) { ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second) defer cancel() ctrl := gomock.NewController(t) proc := testutil.NewProcess(t) proc.Ctx = defines.AttachAccountId(ctx, catalog.System_Account) proc.ReplaceTopCtx(proc.Ctx) service := proc.GetService() const registryID uint64 = 41 op := mock_frontend.NewMockTxnOperator(ctrl) op.EXPECT().Txn().Return(txn.TxnMeta{ ID: []byte("truncate"), LockService: service, Mode: txn.TxnMode_Pessimistic, Isolation: txn.TxnIsolation_RC, }).AnyTimes() op.EXPECT().TxnOptions().Return(txn.TxnOptions{}).AnyTimes() op.EXPECT().CreateTS().Return(timestamp.Timestamp{}).AnyTimes() op.EXPECT().HasLockTable(registryID).Return(tc.retained) var pending atomic.Int32 op.EXPECT().AddWaitLock(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn( func(uint64, [][]byte, lock.LockOptions) uint64 { pending.Add(1); return 1 }).AnyTimes() op.EXPECT().RemoveWaitLock(gomock.Any()).Do(func(uint64) { pending.Add(-1) }).AnyTimes() op.EXPECT().AddLockTable(gomock.Any()).Return(nil).AnyTimes() proc.Base.TxnOperator = op ls := mock_lock.NewMockLockService(ctrl) ls.EXPECT().GetConfig().Return(lockservice.Config{ServiceID: service}).AnyTimes() ls.EXPECT().GetServiceID().Return(service).AnyTimes() proc.Base.LockService = ls eng := newStubEngine() registry := newStubRelation(catalog.MO_FEATURE_REGISTRY) registry.tableID = registryID eng.dbs[catalog.MO_CATALOG].rels[catalog.MO_FEATURE_REGISTRY] = registry db := newStubDatabase("test") db.rels["t"] = newStubRelation("t") // Indexed tables retain broad admission rather than scalar replacement. db.rels["t"].tableDef = &plan2.TableDef{ TableType: catalog.SystemOrdinaryRel, Indexes: []*plan2.IndexDef{{IndexName: "idx"}}, } eng.dbs["test"] = db requested := make(chan struct{}) release := make(chan struct{}) stop := errors.New("gate owner released") ls.EXPECT().Lock(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn( func(ctx context.Context, table uint64, _ [][]byte, _ []byte, opts lock.LockOptions) (lock.Result, error) { if table != registryID { return lock.Result{LockedOn: lock.LockTable{Table: table, Group: opts.Group, Valid: true}}, nil } close(requested) if opts.Mode != lock.LockMode_Exclusive { return lock.Result{}, errors.New("TRUNCATE must retain exclusive admission") } if opts.Policy == lock.WaitPolicy_FastFail { return lock.Result{}, moerr.NewLockConflict(ctx) } select { case <-release: return lock.Result{}, stop case <-ctx.Done(): return lock.Result{}, ctx.Err() } }).AnyTimes() c := &Compile{e: eng, proc: proc} s := &Scope{Plan: &plan2.Plan{Plan: &plan2.Plan_Ddl{Ddl: &plan2.DataDefinition{ Definition: &plan2.DataDefinition_TruncateTable{TruncateTable: &plan2.TruncateTable{ Database: "test", Table: "t", TableId: 1, }}, }}}} result := make(chan error, 1) var worker sync.WaitGroup worker.Add(1) defer func() { cancel(); worker.Wait() }() go func() { defer worker.Done(); result <- s.TruncateTable(c) }() select { case <-requested: case <-ctx.Done(): t.Fatal("TRUNCATE did not request lifecycle admission") } if tc.cancel { cancel() } else if !tc.retained { close(release) } select { case err := <-result: if tc.retained { require.True(t, moerr.IsMoErrCode(err, moerr.ErrLockConflict), "%v", err) } else if tc.cancel { require.ErrorIs(t, err, context.Canceled) } else { require.ErrorIs(t, err, stop) } case <-time.After(10 * time.Second): t.Fatal("TRUNCATE did not leave admission after release/cancel") } require.Zero(t, pending.Load(), "admission must remove wait bookkeeping on every exit") }) - Commit adding the test: 7391899
- Related [Bug]: Concurrent TRUNCATE on unrelated databases fast-fails on global SNAPSHOT gate #29814 tracks user-visible fast-fail conflicts for concurrent TRUNCATEs in independent databases; its trigger and observable failure differ from this unit-test failure.
- Related [Bug]: Slow DROP DATABASE blocks unrelated database DDL on the global SNAPSHOT lifecycle gate #29400 tracks unrelated DDL waiting behind a deliberately slow DROP DATABASE; it is a separate convoy scenario.
Activity
gouhongshen commentedon Oct 12, 2026
CI reproduction from PR #29958; the failure is outside that PR's file scope.
d2de51e389c9cc98d8f48cb0cff6fe880ca3c437.TestTruncateLifecycleRCWaitPolicysubtests failed after 10 seconds. Each log reports an unexpectedMockTxnOperator.Snapshotcall atpkg/sql/compile/lifecycle_admission.go:100, no expectedHasLockTable(41)call, thenddl_test.go:3658: TRUNCATE did not request lifecycle admission. Thepkg/sql/compilepackage failed after 42.799 seconds.pkg/sql/compile. Its current base02a2823c2007d5e4fb4ada148e93743df337551acontains this test, introduced by #29827.iamlinjunhong commentedon Oct 12, 2026
Independent coverage-CI occurrence and current-main comparison
This CI occurrence was inspected for PR #29969 at exact head
3c21381bd3a6f01c3c56a0569eaa596f69e6f2a2.go test -mod=readonly -count=1 -json -short -v -tags matrixone_test -timeout=20m -p 8 -covermode=set -coverprofile=<profile> -coverpkg=<all-package scope> <package scope>, with the workflow's native CGo flags; Linux/amd64, Go 1.27.1, no race flag.Fail on coverage UT failure; there are no build failures. Two failing cases are tracked separately in [Bug]: TopN unsupported-order-type UT still rejects T_any after NULL comparator support #29968 and [CI] TestTruncateLifecycleRCWaitPolicy fails on clean main #29971.A clean, detached official-main comparison was run at freshly fetched
up/main=02a2823c2007d5e4fb4ada148e93743df337551a, inside the current Loom lane. The same focused command was run on this base and the PR head:Both commands terminate with exit 1 and the same normalized failure signatures. Local platform is Darwin/arm64, Go 1.27.1, CGo enabled; this focused comparison uses the same short/tag/coverage mode but narrows package coverage and timeout, and is not a claim of a full Linux CI reproduction. Main is clean before and after; the wrapper verifies platform-matched native provenance and reuses only this lane's native artifacts.
The indexed-table fixture routes
Scope.TruncateTable -> admitBroadTableLifecycleRC -> admitLifecycleRC. Current admission obtains retained ownership throughSnapshot().LockTables, but the test has no Snapshot expectation and instead expects the oldHasLockTable(41)call. The unexpected mock call terminates the worker before either therequestedsignal or the result send; its deferred WaitGroup completion still runs. Each parent subtest then reaches its 10-second context deadline. Thus the 30-second symptom is explained by a deterministic mock-contract mismatch, and this reproduction does not establish a production TRUNCATE lock deadlock.All involved files (
pkg/sql/compile/ddl.go,ddl_test.go,lifecycle_admission.go, plus mock/transaction/lock inputs) are unchanged between current main and this PR. The complete PR's TIME parser/assignment changes are not on this admission path; neither failure test nor the coverage harness is modified. The clean-current-main result closes the original report's gap between previously executed base7391899dband observed latest main02a2823c20.Exact-head changed-closure evidence is green in this same Linux coverage job: full packages
pkg/container/types(2.567s),pkg/sql/colexec/external(36.158s),pkg/sql/plan(44.892s), andpkg/sql/plan/function(12.266s) all have terminal PASS events in artifactut-coverage-diagnostics-attempt-1(artifact ID 11727496536). All seven directly relevant named regressions also pass, including the typed/staged assignment executor, fractional modes, Parquet precision, and extreme signed-duration cases. A focused local run of these seven regressions on the exact head independently terminated with exit 0. This supports the TIME change closure; the workflow as a whole remains red/pending.One failed-jobs rerun of run
38204022899is authorized after the current attempt finishes. These are deterministic upstream test failures; the rerun will not be reported as proof that either defect is fixed. No source code was changed during this CI investigation.The downstream
Matrixone Coverage execution / Coveragejob has also failed in this attempt: https://github.com/matrixorigin/matrixone/actions/runs/38204022899/job/114675562857. Its full job log showsVerify coverage prerequisitesexiting 1 withcoverage merge blocked: a required producer did not publish a complete coverage profile; no coverage verdict was calculated. The UT producer profile upload was skipped after the failures above. This is a consequence of producer failure, not a calculated changed-code coverage rejection.iamlinjunhong commentedon Oct 12, 2026
Additional local rebase-validation evidence for PR #29152.
The repair task started at remote head
388010f0f0ef9133c4f7a89e957fd515e5302327; rebasing its unchanged 219-commit patch series onto current officialup/mainat02a2823c2007d5e4fb4ada148e93743df337551aproduced local validation head8ea6bfda5f3dc0eec841689ced28b0211d9940a5. This record is a local post-rebase reproduction, not a claim that the original-head CI ran the newly added TRUNCATE test. The original-head Coverage UT failure is the separate ANY assertion tracked in #29968.The complete planner/compile/colexec owning-package run passes planner and colexec, but compile fails only
TestTruncateLifecycleRCWaitPolicy. The identical focused command on the rebased candidate and a separate clean detached current official-main worktree reproduces all three failures:GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test -p=2 -short -tags matrixone_test -v -count=1 -timeout=180s -run '^TestTruncateLifecycleRCWaitPolicy$' ./pkg/sql/compileBoth exit 1, with
Unexpected MockTxnOperator.Snapshotatlifecycle_admission.go:100, missingHasLockTable(41), andddl_test.go:3658: TRUNCATE did not request lifecycle admission. Each subtest reaches its 10-second context deadline; total test duration is approximately 30 seconds. The candidate and baseline have byte-identicalddl.go,ddl_test.goandlifecycle_admission.go. The current admission reads retained ownership usingSnapshot().LockTables, while this new fixture provides no Snapshot expectation and expects HasLockTable. The unexpected mock call exits the worker before the requested/result signals, explaining the bounded waits without establishing a production TRUNCATE deadlock.Local platform: Darwin/arm64, Go 1.27.1, CGo enabled, same verified read-only native inputs. Baseline Git status is empty before and after; temporary native-input links were removed through the installed cleanup trap, and the owned clean validation worktree was removed. No DDL/admission/test assertion is changed in this Python UDF PR.
The candidate's full planner and colexec packages, actual
TestV4015LoginRepairsLegacyRoutineCatalogconsumer, go vet and configured golangci-lint pass. The compile package is explicitly recorded as failed with the clean-main control above, not reported green. Delivery uses a precise lease push after rebase and triggers new CI; the superseded old workflow is not rerun.gouhongshen commentedon Oct 12, 2026
CI reproduction record from #29798:
Matrixone UT Coverage execution / UT Coverage on Ubuntu/x86; run38204952772, job114666480658, attempt 1.cba088b792357677dde783a44340ac0ace779dc0, base02a2823c2007d5e4fb4ada148e93743df337551a.TestTruncateLifecycleRCWaitPolicyfails in all three subtests after about 10 seconds each. The log records an unexpectedMockTxnOperator.Snapshotcall atlifecycle_admission.go:100,TRUNCATE did not request lifecycle admission, and the missing expectedHasLockTable(41)call.lifecycle_admission.goor theTestTruncateLifecycleRCWaitPolicyfixture; itspkg/sql/compilechanges are ALTER COPY-specific.gouhongshen commentedon Oct 12, 2026
Additional exact-head reproduction from #29798:
Matrixone UT Coverage execution / UT Coverage on Ubuntu/x86; run38210531841, job114683699411, attempt 1.8ba5e146928098ac13d1c1a002be8776a629818c, base02a2823c2007d5e4fb4ada148e93743df337551a.TestTruncateLifecycleRCWaitPolicysubtests fail after 10 seconds each; the log records the unexpectedSnapshotcall, missing lifecycle-admission request, and missing expectedHasLockTable(41)call.lifecycle_admission.goor that TRUNCATE fixture; the prior run’s PR-ownedTestIssue29400...failure is absent after the test-only fix, while this same clean-main failure remains.fix: implement MySQL MEDIUMINT semantics (#29818)
fix: avoid global lineage gate during ALTER COPY preparation (#29798)