← 1.0.0 backlogs ISS-7

internal/cli's open() leaks partition files, as Server.Close did

Type
Bug — resource leak, unreachable today
Found while
SAPE-19
Triage
Defer
Status
Open
Severity
Low — harmless while one command is one process, and only while that holds

Description

open() (internal/cli/cli.go:562) opens a database for a CLI command and returns a closer. A database is not one file: after opened.Keep(folder, settings.Key) the store opens a file per partition it is asked for, each under an exclusive lock of its own. The closer lets go of the leader and the directory lock, and nothing else:

// internal/cli/cli.go:674
return opened, func() { pages.Close(); held.Close() }, nil

opened.Close() — the call that gives the partition files back — is never made.

Evidence

Triage

Does it lose data, break a promise on a public surface, or stop somebody installing and running? No. Nothing is written or lost; the file's contents are committed before the closer runs. Nobody's install or first run is affected. The leaked handles live exactly as long as the process that made them.

Defer. It is a correctness debt whose only trigger is a second open() in one process, and today no code path does that: internal/cli's own package doc says a command is refused while the server is up, and each subcommand is its own process.

Worth being explicit that the reasoning is about the caller, not the code — the code is wrong, and the thing keeping it from mattering is an assumption ("one command, one process") that nothing in the tree enforces.

If deferred, what it costs to wait