Skip to content

fix: respect scheduler CPU limits for RPC workers - #26403

Merged
XuPeng-SH merged 3 commits into
mainfrom
agent/serialize-embedded-race-tests
Jul 29, 2026
Merged

XuPeng-SH merged 3 commits into
mainfrom
agent/serialize-embedded-race-tests

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #26299 and #26316.

What this PR does / why we need it:

The Ubuntu/x86 race job for #26316 failed while pkg/tests/shard was starting
its embedded cluster. The first test timed out in waitAnyShardReadyLocked; a
later nil dereference was secondary because the shared fixture's sync.Once
had already completed without publishing a cluster.

The runner had an 8-CPU scheduling limit but exposed 112 host CPUs through
runtime.NumCPU(). Each embedded TN therefore created 896 transaction RPC
workers (8 * 112). With the existing heavy-package parallelism of 3, several
race-instrumented clusters created thousands of unnecessary workers and
starved HAKeeper startup.

This fixes the resource model rather than changing test scheduling:

  • system initialization never raises a scheduler limit already established by
    the Go runtime or GOMAXPROCS;
  • the default MORPC server-worker count uses runtime.GOMAXPROCS(0), which is
    the capacity available to Go scheduling, instead of host CPU visibility;
  • the existing minimum of 100 workers and multiplier of 8 remain unchanged;
  • explicit server-workers configuration remains authoritative.

There is no package serialization, test-package allowlist, retry, timeout
extension, assertion weakening, or reduction of HEAVY_RACE_PARALLEL.
Bare-metal defaults remain unchanged when GOMAXPROCS == runtime.NumCPU().

Validation

  • go build ./pkg/common/morpc ./pkg/common/system
  • go vet ./pkg/common/morpc ./pkg/common/system
  • focused race stress, each separately with a 30-second budget:
    • TestAdjustConfig: terminal duration below timer resolution, count=100
    • TestDefaultServerWorkers: terminal duration below timer resolution,
      count=100
    • TestEffectiveGoMaxProcs: terminal duration below timer resolution,
      count=100
  • complete owning packages:
    • mo-cgo-test -race -count=1 ./pkg/common/morpc
    • mo-cgo-test -race -count=1 ./pkg/common/system
  • controlled startup with GOMAXPROCS=8 preserved 8 rather than raising it to
    the 24 CPUs visible on the local host
  • concurrently, with GOMAXPROCS=8 and -race:
    • TestPartitionBasedShardCanBeCreated in pkg/tests/shard
    • Test_TxnExecutorExec in pkg/tests/txnexecutor
  • mo-cgo-test -race -count=1 ./pkg/txn/rpc
  • git diff --check origin/main...HEAD

@XuPeng-SH
XuPeng-SH force-pushed the agent/serialize-embedded-race-tests branch from d7e965c to 9aab2c7 Compare July 29, 2026 11:45
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Jul 29, 2026
@XuPeng-SH XuPeng-SH changed the title ci: serialize embedded cluster race tests fix: respect scheduler CPU limits for RPC workers Jul 29, 2026
@XuPeng-SH XuPeng-SH added kind/bug Something isn't working and removed kind/test-ci labels Jul 29, 2026
@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Deep self-review updated on exact head dcec4ac8afd53cb840cf5b785bde661bf6b1bc45.

The production change is appropriate: default MORPC worker sizing now uses the effective runtime CPU budget (GOMAXPROCS) rather than host NumCPU, while preserving explicit config, the minimum of 100 workers, and the existing 8x multiplier. System initialization no longer raises an already-lower scheduler/container limit. This changes startup sizing only; there is no request hot-path cost. In the motivating 8-CPU limit on a 112-CPU host, the default falls from 896 to the existing minimum 100 workers.

Coverage CI exposed an adjacent stale test that equated a GOMAXPROCS(0) query with NumCPU; CI correctly observed 7 vs 8. The assertion now checks current GOMAXPROCS, preserving the API intent without environment-specific values. morpc/system package tests and race tests passed; the cnservice regression passed 20x and 5x under -race. CI restarted on the new head.

@XuPeng-SH
XuPeng-SH marked this pull request as ready for review July 29, 2026 13:16
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH
XuPeng-SH merged commit 2051b9e into main Jul 29, 2026
5 of 8 checks passed
@XuPeng-SH
XuPeng-SH deleted the agent/serialize-embedded-race-tests branch July 29, 2026 13:25
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#26299 and matrixorigin#26316.

## What this PR does / why we need it:

The Ubuntu/x86 race job for matrixorigin#26316 failed while `pkg/tests/shard` was
starting
its embedded cluster. The first test timed out in
`waitAnyShardReadyLocked`; a
later nil dereference was secondary because the shared fixture's
`sync.Once`
had already completed without publishing a cluster.

The runner had an 8-CPU scheduling limit but exposed 112 host CPUs
through
`runtime.NumCPU()`. Each embedded TN therefore created 896 transaction
RPC
workers (`8 * 112`). With the existing heavy-package parallelism of 3,
several
race-instrumented clusters created thousands of unnecessary workers and
starved HAKeeper startup.

This fixes the resource model rather than changing test scheduling:

- system initialization never raises a scheduler limit already
established by
  the Go runtime or `GOMAXPROCS`;
- the default MORPC server-worker count uses `runtime.GOMAXPROCS(0)`,
which is
the capacity available to Go scheduling, instead of host CPU visibility;
- the existing minimum of 100 workers and multiplier of 8 remain
unchanged;
- explicit `server-workers` configuration remains authoritative.

There is no package serialization, test-package allowlist, retry,
timeout
extension, assertion weakening, or reduction of `HEAVY_RACE_PARALLEL`.
Bare-metal defaults remain unchanged when `GOMAXPROCS ==
runtime.NumCPU()`.

## Validation

- `go build ./pkg/common/morpc ./pkg/common/system`
- `go vet ./pkg/common/morpc ./pkg/common/system`
- focused race stress, each separately with a 30-second budget:
- `TestAdjustConfig`: terminal duration below timer resolution,
`count=100`
- `TestDefaultServerWorkers`: terminal duration below timer resolution,
    `count=100`
  - `TestEffectiveGoMaxProcs`: terminal duration below timer resolution,
    `count=100`
- complete owning packages:
  - `mo-cgo-test -race -count=1 ./pkg/common/morpc`
  - `mo-cgo-test -race -count=1 ./pkg/common/system`
- controlled startup with `GOMAXPROCS=8` preserved 8 rather than raising
it to
  the 24 CPUs visible on the local host
- concurrently, with `GOMAXPROCS=8` and `-race`:
  - `TestPartitionBasedShardCanBeCreated` in `pkg/tests/shard`
  - `Test_TxnExecutorExec` in `pkg/tests/txnexecutor`
- `mo-cgo-test -race -count=1 ./pkg/txn/rpc`
- `git diff --check origin/main...HEAD`
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#26299 and matrixorigin#26316.

## What this PR does / why we need it:

The Ubuntu/x86 race job for matrixorigin#26316 failed while `pkg/tests/shard` was
starting
its embedded cluster. The first test timed out in
`waitAnyShardReadyLocked`; a
later nil dereference was secondary because the shared fixture's
`sync.Once`
had already completed without publishing a cluster.

The runner had an 8-CPU scheduling limit but exposed 112 host CPUs
through
`runtime.NumCPU()`. Each embedded TN therefore created 896 transaction
RPC
workers (`8 * 112`). With the existing heavy-package parallelism of 3,
several
race-instrumented clusters created thousands of unnecessary workers and
starved HAKeeper startup.

This fixes the resource model rather than changing test scheduling:

- system initialization never raises a scheduler limit already
established by
  the Go runtime or `GOMAXPROCS`;
- the default MORPC server-worker count uses `runtime.GOMAXPROCS(0)`,
which is
the capacity available to Go scheduling, instead of host CPU visibility;
- the existing minimum of 100 workers and multiplier of 8 remain
unchanged;
- explicit `server-workers` configuration remains authoritative.

There is no package serialization, test-package allowlist, retry,
timeout
extension, assertion weakening, or reduction of `HEAVY_RACE_PARALLEL`.
Bare-metal defaults remain unchanged when `GOMAXPROCS ==
runtime.NumCPU()`.

## Validation

- `go build ./pkg/common/morpc ./pkg/common/system`
- `go vet ./pkg/common/morpc ./pkg/common/system`
- focused race stress, each separately with a 30-second budget:
- `TestAdjustConfig`: terminal duration below timer resolution,
`count=100`
- `TestDefaultServerWorkers`: terminal duration below timer resolution,
    `count=100`
  - `TestEffectiveGoMaxProcs`: terminal duration below timer resolution,
    `count=100`
- complete owning packages:
  - `mo-cgo-test -race -count=1 ./pkg/common/morpc`
  - `mo-cgo-test -race -count=1 ./pkg/common/system`
- controlled startup with `GOMAXPROCS=8` preserved 8 rather than raising
it to
  the 24 CPUs visible on the local host
- concurrently, with `GOMAXPROCS=8` and `-race`:
  - `TestPartitionBasedShardCanBeCreated` in `pkg/tests/shard`
  - `Test_TxnExecutorExec` in `pkg/tests/txnexecutor`
- `mo-cgo-test -race -count=1 ./pkg/txn/rpc`
- `git diff --check origin/main...HEAD`
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#26299 and matrixorigin#26316.

## What this PR does / why we need it:

The Ubuntu/x86 race job for matrixorigin#26316 failed while `pkg/tests/shard` was
starting
its embedded cluster. The first test timed out in
`waitAnyShardReadyLocked`; a
later nil dereference was secondary because the shared fixture's
`sync.Once`
had already completed without publishing a cluster.

The runner had an 8-CPU scheduling limit but exposed 112 host CPUs
through
`runtime.NumCPU()`. Each embedded TN therefore created 896 transaction
RPC
workers (`8 * 112`). With the existing heavy-package parallelism of 3,
several
race-instrumented clusters created thousands of unnecessary workers and
starved HAKeeper startup.

This fixes the resource model rather than changing test scheduling:

- system initialization never raises a scheduler limit already
established by
  the Go runtime or `GOMAXPROCS`;
- the default MORPC server-worker count uses `runtime.GOMAXPROCS(0)`,
which is
the capacity available to Go scheduling, instead of host CPU visibility;
- the existing minimum of 100 workers and multiplier of 8 remain
unchanged;
- explicit `server-workers` configuration remains authoritative.

There is no package serialization, test-package allowlist, retry,
timeout
extension, assertion weakening, or reduction of `HEAVY_RACE_PARALLEL`.
Bare-metal defaults remain unchanged when `GOMAXPROCS ==
runtime.NumCPU()`.

## Validation

- `go build ./pkg/common/morpc ./pkg/common/system`
- `go vet ./pkg/common/morpc ./pkg/common/system`
- focused race stress, each separately with a 30-second budget:
- `TestAdjustConfig`: terminal duration below timer resolution,
`count=100`
- `TestDefaultServerWorkers`: terminal duration below timer resolution,
    `count=100`
  - `TestEffectiveGoMaxProcs`: terminal duration below timer resolution,
    `count=100`
- complete owning packages:
  - `mo-cgo-test -race -count=1 ./pkg/common/morpc`
  - `mo-cgo-test -race -count=1 ./pkg/common/system`
- controlled startup with `GOMAXPROCS=8` preserved 8 rather than raising
it to
  the 24 CPUs visible on the local host
- concurrently, with `GOMAXPROCS=8` and `-race`:
  - `TestPartitionBasedShardCanBeCreated` in `pkg/tests/shard`
  - `Test_TxnExecutorExec` in `pkg/tests/txnexecutor`
- `mo-cgo-test -race -count=1 ./pkg/txn/rpc`
- `git diff --check origin/main...HEAD`

This branch was previously deployed

1 inactive deployment
ci — 8dfa6cdb Deployed Jul 29, 2026 by XuPeng-SH via Matrixone Utils CI / Coverage #43406
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants