Skip to content

bug: failed TN construction leaves an active I/O pipeline without a service owner #29639

Closed

Description

@XuPeng-SH

Description

Refs #29249. Production TN construction can return nil, error after starting its I/O pipeline. The caller receives no service owner to close, while the runtime retains an active pipeline. A fixture that responds by closing borrowed storage can destroy dependencies still owned by that lost producer.

Verified at bdf3c915f1a228dc815f947db7160c557c798a85, Go 1.26.4, using the repository CGo test wrapper with GOMAXPROCS=2, GOMEMLIMIT=2GiB, -p=1 -parallel=1 -count=1.

Reproduction

Two deterministic cases call the actual tnservice.NewService with a unique runtime, MemoryFS, and an existing HAKeeper factory injection:

  1. Runtime has no clock. Constructor returns an error and nil owner.
  2. Runtime has a valid zero-offset clock; HAKeeper factory returns a sentinel error. Constructor returns that sentinel and nil owner.

In both cases, the runtime's blockio is an actual IoPipeline whose active state remains 1 after the synchronous constructor returns; the required value is 0 (or no acquired pipeline). Both assertions fail. Named test: TestQATNFailedConstructionDoesNotLeaveActiveIO, cases missing-clock and hakeeper-factory-error; actual package runtime 0.051s. No network service, cluster, sleeps or large data were used. The probe registers cleanup before construction and explicitly calls ioutil.Stop(sid) afterward, so it does not leave its own workers active.

Source path: pkg/tnservice/store.go starts ioutil.Start(cfg.UUID) before initClocker and initHAKeeperClient; those failures return nil/error without rollback. pkg/objectio/ioutil/pipeline.go publishes the active owner in the service runtime.

Required systemic resolution

Make acquisition and rollback the responsibility of the existing production owner, with one dependency-aware cleanup path. Validate cheap prerequisites before acquisition. Return nil/error only after all acquired consumers have stopped using borrowed dependencies; preserve original error identity. Cover later partial acquisition, panic/unwind where reachable, and real cancellation/join semantics. Audit analogous CN/LOG constructors and existing embed/launcher/standalone consumers before declaring the class closed.

Do not mask the issue with fixture-side unconditional FS.Close, a second resource ledger, or successful-owner-only cleanup. Existing TN cached drain failure and CN local completion certificates must remain conservative: incomplete producers retain storage/admission. Additional CN/LOG defects are audit targets, not claimed runtime reproductions here.

Regression evidence

Retain the two minimal actual-constructor cases and nearby valid-input controls. Prove borrowed FS survives and acquired worker/client owners are retired exactly once on failure. Use existing injections, exact destructor/cancellation counts and terminal results; no sleeps or goroutine-count timing oracle. Reuse appropriate production drain and completion tests, then validate affected fixture consumers, race and incremental static checks.

Activity

  1. self-assigned this
    on Oct 6, 2026
  2. added
    kind/bug
    severity/s0
    on Oct 6, 2026
  3. added a commit that references this issue on Oct 9, 2026
    23d8f61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions