Repository navigation
Description
Is there an existing issue for the same bug?
- I checked existing issues (Dragonboat constructor/panic search found no matching issue).
Branch Name
Current cleanup branch based on main 614ab46453638324a7997ac3ecc6813e5c810309; dependency pin is unchanged.
Commit ID
6655ceef2b587275db1075cdd46bf2a4c60cf1db; github.com/matrixorigin/dragonboat/v4 v4.0.0-20260924043555-37eeca713c36.
Other Environment Information
Linux, Go 1.26.4, GOMAXPROCS=2, GOMEMLIMIT=2GiB, offline modules, repository CGo wrapper. StrictMem VFS; no service topology or network is started.
Actual Behavior
A real dragonboat.NewNodeHost whose configured LogDB factory panics with a string suppresses that panic and returns (nil, nil). A deterministic private overlay UT in pkg/logservice confirmed that the factory ran, logged called=true, owner=<nil>, err=<nil>, and failed the literal panic-preservation assertion. Package terminal exit 1, exactly one selected test, zero skips; VFS cleanup reported no leaked descriptors.
MatrixOne's LOG store uses this pinned constructor. A (nil,nil) constructor result defeats the normal error/ownership boundary; this probe does not claim a production SQL incident or quantify memory leakage.
Expected Behavior
Construction must never convert a failed acquisition into a success-looking (nil,nil). After complete owned rollback, preserve the original panic value. Existing ordinary error identity and Goexit behavior also need to remain correct when the constructor guard is repaired.
Steps to Reproduce
- Configure a
NodeHostConfigwithNodeHostDir: "/qa-constructor",RTTMillisecond: 10,RaftAddress: "127.0.0.1:1", andExpert.FS: vfs.NewStrictMem(). - Supply
Expert.LogDBFactoryimplementingName() stringandCreate(config.NodeHostConfig, config.LogDBCallback, []string, []string) (raftio.ILogDB,error). ItsCreaterecords that it was called and executespanic("qa-constructor-unwind"). - Call the real
NewNodeHostinside an outer recover. Assert that the factory ran and the recovered value equals the literal string. Current code instead returns nil owner/nil error; recovered value is nil.
The failure occurs before transport creation, so the numeric Raft address is configuration only and no port is bound.
Additional information
In the exact pinned nodehost.go, the deferred recovery calls nh.Close() but rethrows only when the recovered value implements error. A string panic is therefore swallowed. The guard is also installed after initial worker/pool acquisition and is recover-based rather than success-based; Goexit/earlier acquisition closure must be examined as part of the repair, but this issue's reproduced failure is specifically the swallowed string panic.
Fix at the existing dependency owner and update MatrixOne's pin. Preserve all panic values with a success-based constructor guard, integrate partial destruction into the same owner, and verify diagnostic/completion behavior without a new generic fatal wrapper or duplicated cleanup path. Add the minimum constructor unwind regression and verify ordinary LOG failure/reopen consumers.
Refs #29249, #29627 and #29639. This is an additional prerequisite of the resource ownership cleanup; not fixed by PR #29638.
Expanded orthogonal unwind QA
The same actual constructor/LogDB acquisition now has one four-case table, with an observed real VFS directory-lock destructor and a controlled goroutine. Normal and race runs both reached all four cases (zero skips):
- Ordinary acquisition error: PASS; original error identity and lock destruction are preserved.
- String panic: FAIL; constructor returns normally instead of propagating the literal value.
- Error-valued panic: FAIL; the original error pointer is replaced by a non-pointer panic during
panicNowlogging. - Goexit: FAIL; constructor goroutine completes but the already acquired directory lock has zero Close calls. The probe checks this before its separately registered fallback cleanup releases that exact lock.
No race detector report or cleanup FD failure occurred. Each mode uses a fresh StrictMem filesystem and exits before transport creation. This proves an actual missing lock destructor on Goexit; it does not claim that all NodeHost background workers or real production FDs were measured. Treat these as one constructor-unwind responsibility, with ordinary error as its passing control, rather than separate per-value fixes.
Activity
fix(logservice): preserve Dragonboat constructor unwind and cleanup (#…