Skip to content

[Bug]: TestGetBackendWithCreateBackend races process-wide MORPC idle GC #27835

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

  • I have checked the existing issues.

The closed issues #23581 and #26649 document related, test-specific races with the process-wide MORPC idle-GC loop, but neither tracks this test or assertion. Their corresponding test fixes do not cover TestGetBackendWithCreateBackend.

Branch Name

main

Commit ID

6fb0573b9d4b4ced0a0339e01cabec2a7e94f53c

Other Environment Information

- Workflow: MatrixOne ALL CI
- Job: Matrixone CI / UT Test on Ubuntu/x86
- Workflow run 33230446268, attempt 1, failed job 99042307493
- Runner: Ubuntu 22.04, Go 1.26.4, race-enabled repository UT wrapper

Actual Behavior

The Ubuntu UT job fails in pkg/common/morpc because TestGetBackendWithCreateBackend has a data race with the process-wide idle-GC goroutine. The failure is reported at:

WARNING: DATA RACE
Write: (*client).closeIdleBackends() at pkg/common/morpc/client.go:1873
Previous read: TestGetBackendWithCreateBackend() at pkg/common/morpc/client_test.go:1705
--- FAIL: TestGetBackendWithCreateBackend
    testing.go:1712: race detected during execution of test

The test reads len(c.mu.backends["b1"]) after getBackend returns without holding c.mu. The global clientGCManager may concurrently run closeIdleBackends, which rebuilds the same backend slice and assigns it back into the map while holding c.mu. The test therefore races with a legitimate client lifecycle operation and intermittently fails the race-enabled UT job.

Expected Behavior

TestGetBackendWithCreateBackend should inspect the client backend state under the same mutex used by the client and idle-GC lifecycle, so the test remains race-free while preserving its backend-creation assertion.

Steps to Reproduce

  1. Run the focused test under the race detector:

    go test -race ./pkg/common/morpc -run '^TestGetBackendWithCreateBackend$' -count=100
  2. Run the repository Ubuntu UT workflow or its race-enabled MORPC package phase on a runner where the process-wide idle-GC goroutine is active.

  3. Observe the race report between closeIdleBackends and the direct c.mu.backends["b1"] read.

Additional information

Related historical fixes

Activity

  1. self-assigned this
    on Aug 29, 2026
  2. added
    kind/bug
    severity/s0
    ai-easy
    and removed on Aug 29, 2026
  3. gouhongshen commented on Aug 29, 2026

    @gouhongshen
    ContributorAuthor

    PR #27837 is trying to fix this issue.

  4. gouhongshen commented on Aug 29, 2026

    @gouhongshen
    ContributorAuthor

    PR #27837 has merged and is awaiting manual validation. The issue remains open.

  5. gouhongshen commented on Oct 21, 2026

    @gouhongshen
    ContributorAuthor

    Reproduction record: the same process-wide idle-GC race recurred in TestMaybeCreateLockedWithNotFullBackendsAndNoBusy (no new issue filed; this closed issue is the standing record of this mechanism)

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

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions