Skip to content

fix: preserve NodeHost constructor unwind and release partial resources - #18

Merged
volgariver6 merged 3 commits into
masterfrom
fix/nodehost-constructor-unwind
Oct 7, 2026
Merged

volgariver6 merged 3 commits into
masterfrom
fix/nodehost-constructor-unwind

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 6, 2026 •

Copy link
Copy Markdown

NewNodeHost previously swallowed non-error panics, changed error-valued panic identity and leaked its directory lock on Goexit. NewTransport could also lose an acquired child before handoff. Keep rollback at each existing constructor owner until successful return, reuse the shared destruction paths, and remove recovery/type filtering and duplicate error-branch cleanup.

Transport shutdown now stops and joins its receiver before cleaning snapshot chunks. A final admitted receive can otherwise recreate .receiving storage after cleanup. The same close path covers ordinary shutdown and partial-start rollback; returned child Close errors are preserved and do not skip chunk cleanup.

Existing EngineConfig validation rejects snapshot/close worker counts exceeding Go's 65,536-case reflect.Select limit. This closes the impossible-length configuration boundary without adding engine rollback state, arbitrary limits on other shard counts, or another cleanup framework. Default configurations, APIs and wire/persisted formats are unchanged. All added work is in construction or shutdown.

Focused tests reuse existing factories, NOOP transport and StrictMem fixtures. They cover error/panic/Goexit identity, exactly-once resource cleanup, successful handoff, a valid final snapshot chunk during receiver drain with both Close outcomes, and configuration rejection before acquisition. No sockets, sleeps, large data or production test hooks are added.

Validation (Go 1.26.4, Linux/amd64):

  • Prior implementations fail the new ownership, terminal snapshot-directory and unsafe-count oracles; passing controls distinguish ordinary error and success.
  • Config/root/transport owning packages normal PASS (0.003s/84.072s/37.058s), race PASS (1.013s/143.611s/35.393s).
  • Exact receiver-drain regression ×100 race PASS; nine actual-constructor QA cells PASS under race, including late panic/Goexit and cleanup-error controls.
  • Incremental formatting, vet and configured lint for config/root/transport PASS, zero introduced issues. Legacy lint policy is translated outside tracked source for the current Go toolchain.
  • MatrixOne full logservice normal/race PASS (104.129s/109.050s) against this exact dependency source. Required gpt-6.1-sol/xhigh design and overall review evidence is recorded.

Refs matrixorigin/matrixone#29641. Companion integration: matrixorigin/matrixone#29649. Merge this dependency PR first. Custom child Close retains its existing requirement to terminate and join callbacks; factory-internal resources not returned and arbitrary fatal/nonterminating destructors keep their existing contracts. Hard select limits are not an affordability guarantee for extremely large worker configurations. Hosted CI is reported separately from local validation.

@volgariver6
volgariver6 merged commit 18a1f46 into master Oct 7, 2026
XuPeng-SH added a commit to matrixorigin/matrixone that referenced this pull request Oct 7, 2026
…29649)

## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

Fixes #29641

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

Dragonboat NewNodeHost swallowed non-error panics, changed error-valued
panic identity and leaked its directory lock on Goexit. NewTransport
could also lose a returned child before constructor handoff. Pin
Dragonboat to `abc3d2fce5a6b82b3a8a922c342fd1ec4afb8df3`
(matrixorigin/dragonboat#18): each existing
constructor owner keeps rollback until successful return and reuses its
shared destruction path, preserving the primary failure.

Transport Close now stops and joins the receiver before cleaning
snapshot chunks. Otherwise a final valid receive can recreate
`.receiving` storage after cleanup. The shared path covers ordinary
shutdown and partial-start rollback, including returned child Close
errors. Existing EngineConfig validation also rejects snapshot/close
worker counts beyond Go's reflect.Select hard limit before acquisition.
No new state machine, engine rollback framework or steady-state work is
added.

Remove the unused testutil import that blocked this branch's
function-package compilation. This matches the existing correction on
main (#29648), without pulling in its other changes.

The MatrixOne regression exercises the actual public constructor with
StrictMem LogDB injection and no bound ports, checking ordinary errors,
panic identity, Goexit and exactly-once lock cleanup. Dependency
regressions reuse existing fixtures and validate ownership handoff,
receiver draining with both Close outcomes, terminal snapshot-directory
cleanup, and unsafe configuration rejection before acquisition.

Validation (Go 1.26.4, Linux/amd64):
- Prior implementations fail the new ownership, terminal-directory and
invalid-worker-count oracles; passing ordinary-error/success controls
distinguish the defects.
- Dragonboat config/root/transport packages normal and race PASS.
Receiver-drain regression ×100 race PASS; nine actual-constructor QA
cases PASS under race.
- Full MatrixOne pkg/logservice normal/race PASS (104.129s/109.050s).
Six existing function execution-contract tests normal/race PASS.
Published-pin constructor and actual LOG create/close/retry consumers
PASS under race.
- Incremental formatting, vet and configured golangci-lint PASS for
affected packages, with zero introduced findings. MatrixOne molint
completes successfully; its two unchanged baseline checkunsafe
diagnostics are outside this delta.
- Downloaded dependency origin/checksums verified; 41 relevant
module/config/root/transport files match the tested source byte for
byte. Required gpt-6.1-sol/xhigh design, overall review and final
pin/evidence reconciliation are recorded.

Merge Dragonboat #18 first. Custom child Close retains its requirement
to terminate and join callbacks; resources a factory never returns and
arbitrary fatal/nonterminating destructors retain their existing
contracts. Hard worker-count limits do not guarantee affordability of
extremely large configurations. Local validation is distinct from hosted
CI; new-head CI is not claimed green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants