Skip to content

Fix socket leak, clean up single use postgres databases#2413

Merged
spikecurtis merged 3 commits into
mainfrom
spike/2347_postgres_flakes
Jun 16, 2022
Merged

Fix socket leak, clean up single use postgres databases#2413
spikecurtis merged 3 commits into
mainfrom
spike/2347_postgres_flakes

Conversation

@spikecurtis
Copy link
Copy Markdown
Contributor

First PR for #2347

This fixes up a socket leak in our use of Migrate.

It also introduces cleanup of single-use databases in postgres, since the postgres container outlives the test run, if we don't clean up these databases the container will continue to grow in size until it is restarted.

Lastly, this extends the timeout for postgres tests to 30 minutes. I'm seeing several minutes on my machine, and we don't want to set this aspirationally---it's a backstop for when things are going really wrong. It removes the limit of 1 parallel test per package, on the theory that the socket leak was actually the source of our CI problems. We can add parallel limits back in if the CI buckles under this pressure.

@spikecurtis spikecurtis requested a review from a team June 16, 2022 15:27

// MigrateUp runs SQL migrations to ensure the database schema is up-to-date.
func MigrateUp(db *sql.DB) error {
func MigrateUp(db *sql.DB) (retErr error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip (non-blocking): It would be OK to call this err, at the time defer func runs, the value of err would be that of the return statement.

Comment thread coderd/database/migrate.go
Signed-off-by: Spike Curtis <spike@coder.com>
@spikecurtis spikecurtis merged commit a82c0eb into main Jun 16, 2022
@spikecurtis spikecurtis deleted the spike/2347_postgres_flakes branch June 16, 2022 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants