Repository navigation
Agent/fix 26299 hakeeper startup cleanup - #26316
mergify[bot] merged 10 commits into
Conversation
Use a longer HAKeeper-running deadline only for embedded test clusters, and ensure the txn executor cluster is closed even when startup fails. Also propagate base-cluster startup failures.\n\nRefs matrixorigin#26299.
Close every started or partially initialized service after startup failure, continue cleanup past individual close errors, and make repeated cleanup safe. Roll back failed dynamic CN additions without stopping the running cluster.\n\nRefs matrixorigin#26299.
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed latest head eac719010d2ac6f79f0563aecf7991c6f0289a68 across initial startup, partial service construction, reverse-order close, repeated close, dynamic CN rollback, file-service cleanup, and the CI timeout change. The timeout is test-only and does not affect production or the successful startup path, but two real cleanup/state blockers remain.
P1 — Rollback still cannot close services whose Start/Bootstrap partially failed
The concrete service is assigned to op.reset.svc only after all startup work succeeds: LOG at pkg/embed/operator.go:226-245, TN at :260-273, and CN at :286-302. If s.Start() returns after starting an earlier component (CN starts query/frontend/RPC stages sequentially), or LOG BootstrapHAKeeper fails after the service is running, operator.Start returns with reset.svc == nil. cluster.Start then calls the new rollback, but operator.Close has no service handle and only stops the outer stopper/file service. The partially started service can retain goroutines/listeners and its own resources. Store ownership immediately after construction and make rollback close it on every later error. The new startFn test pre-populates reset.svc, so it cannot catch this production path.
P1 — A close error leaves a failed dynamic CN in the active cluster topology
rollbackNewServicesLocked truncates services, files, and restores options.cn only when every close returned nil (pkg/embed/cluster.go:260-267). CN Close legitimately aggregates RPC/query/gossip errors. On such an error, StartNewCNService returns failure but the cluster remains started while GetCNService/ForeachServices expose the failed, partly closed CN and subsequent additions use the inflated CN count/config sequence. Logical rollback must happen regardless of cleanup errors; retain any still-owned cleanup handles separately if retries are required. Add an unhappy-path test with a new CN whose Close returns an error.
The PR is also now genuinely conflicting with latest main: #26203 changed RunBaseClusterTests to take t, while this branch changes its old return-value form. Please rebase/merge and preserve the main-side startup-error propagation when resolving it.
…eeper-startup-cleanup # Conflicts: # pkg/tests/txnexecutor/txn_executor_test.go
## 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 #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`
Merge Queue Status
This pull request spent 26 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #26299
What this PR does / why we need it:
Agent/fix 26299 hakeeper startup cleanup