Skip to content

Process leak on startup error in startDB() #4815

@e-gineer

Description

@e-gineer

Description

In startDB(), if an error occurs after the postgres process is started but before Process.Release() is called, the defer block attempts cleanup. However, if the postgres command's Process field is nil or if Process.Kill() fails, the postgres process may not be terminated, leading to an orphaned process.

Severity

HIGH - Resource leak (orphaned process)

Test Reference

Test: TestStartDB_ProcessCleanupOnError in pkg/db/db_local/start_services_test.go:237 (skipped - requires mocking)

Suggested Fix

Ensure robust cleanup even in error paths, possibly using process groups and verifying process termination.

Related Code

  • pkg/db/db_local/start_services.go:226-244

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions