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
Description
In
startDB(), if an error occurs after the postgres process is started but beforeProcess.Release()is called, the defer block attempts cleanup. However, if the postgres command'sProcessfield is nil or ifProcess.Kill()fails, the postgres process may not be terminated, leading to an orphaned process.Severity
HIGH - Resource leak (orphaned process)
Test Reference
Test:
TestStartDB_ProcessCleanupOnErrorinpkg/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