Skip to content

[CI] TestTruncateLifecycleRCWaitPolicy fails on clean main #29971

Closed

Description

@Lundomn

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/compile

The 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:
    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

  1. self-assigned this
    on Oct 12, 2026
  2. gouhongshen commented on Oct 12, 2026

    @gouhongshen
    Contributor

    CI reproduction from PR #29958; the failure is outside that PR's file scope.

    • Workflow/job/run: MatrixOne ALL CI — UT Coverage on Ubuntu/x86, run 38204783727, attempt 1, checked head d2de51e389c9cc98d8f48cb0cff6fe880ca3c437.
    • All three TestTruncateLifecycleRCWaitPolicy subtests failed after 10 seconds. Each log reports an unexpected MockTxnOperator.Snapshot call at pkg/sql/compile/lifecycle_admission.go:100, no expected HasLockTable(41) call, then ddl_test.go:3658: TRUNCATE did not request lifecycle admission. The pkg/sql/compile package failed after 42.799 seconds.
    • The PR diff does not modify pkg/sql/compile. Its current base 02a2823c2007d5e4fb4ada148e93743df337551a contains this test, introduced by #29827.
    • This matches the mock/setup failure already recorded for a clean base in this issue; the CI failure is unrelated to PR Clarify snapshot restore and branch merge diagnostics #29958. The failed job log is linked above.
  3. iamlinjunhong commented on Oct 12, 2026

    @iamlinjunhong
    Contributor

    Independent coverage-CI occurrence and current-main comparison

    This CI occurrence was inspected for PR #29969 at exact head 3c21381bd3a6f01c3c56a0569eaa596f69e6f2a2.

    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:

    .agents/skills/mo-dev/scripts/mo-cgo-test \
      -short -v -count=1 -tags matrixone_test -timeout=120s -p 8 \
      -covermode=set -coverprofile=<TMPDIR/profile> \
      -coverpkg=./pkg/sql/colexec/partition,./pkg/sql/compile \
      -run '^(TestPartitionTopNRejectsUnsupportedOrderType|TestTruncateLifecycleRCWaitPolicy)$' \
      ./pkg/sql/colexec/partition ./pkg/sql/compile

    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.

    lifecycle_admission.go:100: Unexpected call to MockTxnOperator.Snapshot because there are no expected calls
      ddl_test.go:3658: TRUNCATE did not request lifecycle admission
      missing call(s): MockTxnOperator.HasLockTable(41), ddl_test.go:3599
    --- FAIL: TestTruncateLifecycleRCWaitPolicy (30.00s)
      --- FAIL: fresh_owner_waits (10.00s)
      --- FAIL: fresh_wait_can_be_canceled (10.00s)
      --- FAIL: retained_owner_fails_promotion (10.00s)
    

    The indexed-table fixture routes Scope.TruncateTable -> admitBroadTableLifecycleRC -> admitLifecycleRC. Current admission obtains retained ownership through Snapshot().LockTables, but the test has no Snapshot expectation and instead expects the old HasLockTable(41) call. The unexpected mock call terminates the worker before either the requested signal 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 base 7391899db and observed latest main 02a2823c20.

    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), and pkg/sql/plan/function (12.266s) all have terminal PASS events in artifact ut-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 38204022899 is 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 / Coverage job has also failed in this attempt: https://github.com/matrixorigin/matrixone/actions/runs/38204022899/job/114675562857. Its full job log shows Verify coverage prerequisites exiting 1 with coverage 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.

  4. iamlinjunhong commented on Oct 12, 2026

    @iamlinjunhong
    Contributor

    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 official up/main at 02a2823c2007d5e4fb4ada148e93743df337551a produced local validation head 8ea6bfda5f3dc0eec841689ced28b0211d9940a5. 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/compile

    Both exit 1, with Unexpected MockTxnOperator.Snapshot at lifecycle_admission.go:100, missing HasLockTable(41), and ddl_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-identical ddl.go, ddl_test.go and lifecycle_admission.go. The current admission reads retained ownership using Snapshot().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 TestV4015LoginRepairsLegacyRoutineCatalog consumer, 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.

  5. gouhongshen commented on Oct 12, 2026

    @gouhongshen
    Contributor

    CI reproduction record from #29798:

  6. gouhongshen commented on Oct 12, 2026

    @gouhongshen
    Contributor

    Additional exact-head reproduction from #29798:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions