Skip to content

[Bug]: nil pointer panic in MergeScheduler.doSched when table dropped during merge scheduling #24446

Closed

Description

@xzxiong

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

3.0-dev / v3.0.11-6a0394c4f-2026-05-11

Commit ID

6a0394c

Other Environment Information

- Hardware parameters: IDC bare-metal, 14P
- OS type: Linux
- MO version: v3.0.11-6a0394c4f-2026-05-11
- Scenario: After tenant upgrade DDL (902 tenants, drop/create information_schema.statistics)

Actual Behavior

TN panics with nil pointer dereference in MergeScheduler.doSched at scheduler.go:1048.

The panic occurs because a.supps[todo.table.ID()] returns nil (the table was dropped during tenant upgrade DDL), but doSched accesses supp.mergingTaskCnt without a nil check.

Panic stack:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2d604ae]

goroutine 9080 [running]:
github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/merge.(*MergeScheduler).doSched(0xc094790a00, 0xc02577b8c0)
	/go/src/github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/merge/scheduler.go:1048 +0x1ee
github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/merge.(*MergeScheduler).handleMainLoop(0xc094790a00)
	/go/src/github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/merge/scheduler.go:788 +0x56a
created by github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/merge.(*MergeScheduler).Start in goroutine 1007
	/go/src/github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/merge/scheduler.go:153 +0xc5

Relevant code at line 1048:

supp := a.supps[todo.table.ID()]

now := a.clock.Now()

// this table is merging, postpone the task
if supp.mergingTaskCnt > 0 {  // <-- line 1048, supp is nil here
    a.pq.Update(todo, now.Add(a.baseInterval/2))
    return
}

Expected Behavior

doSched should check supp == nil and return early (similar to the fix in dispatchMsg from #22697).

Steps to Reproduce

  1. Deploy MO cluster with many tenants (900+)
  2. Trigger tenant upgrade that performs mass DDL (drop/create information_schema.statistics for each tenant)
  3. TN merge scheduler picks up a todo item for a table that was just dropped
  4. a.supps[todo.table.ID()] returns nil → panic

Additional information

This is the same class of bug as #22695 / #22697, but in a different code path. PR #22697 added a nil check in dispatchMsg, but missed the same pattern in doSched. The fix should be:

supp := a.supps[todo.table.ID()]
if supp == nil {
    // table has been dropped and removed from supps, skip
    return
}

cc @aptend

Activity

  1. added
    kind/bug
    on May 18, 2026
  2. xzxiong commented on May 18, 2026

    @xzxiong
    ContributorAuthor

    Workaround

    Disable merge scheduler globally via mo_ctl to prevent repeated TN panics until the fix is available:

    -- Disable merge to stop panic loop
    SELECT mo_ctl('dn', 'inspect', 'merge switch off');
    
    -- Verify merge is disabled
    SELECT mo_ctl('dn', 'inspect', 'merge show');
    
    -- Re-enable after fix is deployed
    SELECT mo_ctl('dn', 'inspect', 'merge switch on');

    Note: Disabling merge will cause object accumulation over time. Re-enable once the fix is available.

  3. added theissue type on May 18, 2026
  4. added this to the MO-202605 milestone on May 18, 2026
  5. ghost added a commit that references this issue on May 20, 2026
  6. aptend commented on May 21, 2026

    @aptend
    Contributor

    fixed

  7. assigned and unassigned on May 21, 2026
  8. ghost closed this as completedon May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugseverity/s-1

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions