Repository navigation
fix: respect scheduler CPU limits for RPC workers - #26403
Conversation
d7e965c to
9aab2c7
Compare
|
Deep self-review updated on exact head The production change is appropriate: default MORPC worker sizing now uses the effective runtime CPU budget ( Coverage CI exposed an adjacent stale test that equated a |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
## 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`
## 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`
## 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`
What type of PR is this?
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/shardwas startingits embedded cluster. The first test timed out in
waitAnyShardReadyLocked; alater nil dereference was secondary because the shared fixture's
sync.Oncehad 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 RPCworkers (
8 * 112). With the existing heavy-package parallelism of 3, severalrace-instrumented clusters created thousands of unnecessary workers and
starved HAKeeper startup.
This fixes the resource model rather than changing test scheduling:
the Go runtime or
GOMAXPROCS;runtime.GOMAXPROCS(0), which isthe capacity available to Go scheduling, instead of host CPU visibility;
server-workersconfiguration 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/systemgo vet ./pkg/common/morpc ./pkg/common/systemTestAdjustConfig: terminal duration below timer resolution,count=100TestDefaultServerWorkers: terminal duration below timer resolution,count=100TestEffectiveGoMaxProcs: terminal duration below timer resolution,count=100mo-cgo-test -race -count=1 ./pkg/common/morpcmo-cgo-test -race -count=1 ./pkg/common/systemGOMAXPROCS=8preserved 8 rather than raising it tothe 24 CPUs visible on the local host
GOMAXPROCS=8and-race:TestPartitionBasedShardCanBeCreatedinpkg/tests/shardTest_TxnExecutorExecinpkg/tests/txnexecutormo-cgo-test -race -count=1 ./pkg/txn/rpcgit diff --check origin/main...HEAD