db: harden Postgres fixture cleanup - #867
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies db/test_postgres.go to improve resource cleanup and error handling during test database setup. Specifically, it ensures that sqlFixture.TearDown is called if NewPostgresStore fails, adds a defensive comment regarding sequential dbPath reopening, and reorders the operations in t.Cleanup so that the fixture is removed from the global map before being torn down. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR hardens the lifecycle of Postgres test fixtures in db to prevent resource/semaphore leaks and reduce the chance that any code observes a fixture while it is tearing down, building on the fixture-cache changes introduced in #864.
Changes:
- Ensure a newly created Postgres fixture is torn down if the initial
NewPostgresStoreopen/migration step fails. - Evict
dbPathcache entries before purging the fixture container duringt.Cleanup. - Add a short comment clarifying the “duplicate creator” branch as a defensive invariant guard.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Review comment analysis
NewTestPgFixture, aNewPostgresStorefailure could skipTearDownand leak the fixture semaphore slot.Verification
go test -tags="dev test_postgres nolog" ./db -run '^$'make fmt-changedmake lint-changed-localFollow-up to #864.