-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: only connect to the database once #9456
Conversation
✅ Deploy Preview for determined-ui canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9456 +/- ##
=======================================
Coverage 48.57% 48.58%
=======================================
Files 1233 1233
Lines 159168 159158 -10
Branches 2777 2777
=======================================
+ Hits 77312 77322 +10
+ Misses 81682 81662 -20
Partials 174 174
Flags with carried forward coverage won't be shown. Click here to find out more.
|
master/internal/db/postgres.go
Outdated
func databaseIsFresh() (bool, error) { | ||
fresh, err := Bun().NewSelect().Table("pg_tables"). | ||
Where("schemaname = ?", "public"). | ||
Where("tablename = ?", "gopg_migrations"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why this is being done dynamically? Do we plan to parameterize this query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched to just using tablename = "gopg..."
master/internal/db/setup.go
Outdated
} | ||
if !exist["gopg_migrations"] { | ||
return true, nil | ||
return db, false, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (non-blocking): is there a benefit to returning the db pointer if an error occurs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope that was a mistake, should return nil
master/internal/db/setup.go
Outdated
|
||
exist, err := tablesExist(pgConn, []string{"gopg_migrations", "schema_migrations"}) | ||
// Setup connects to the database and run any necessary migrations. | ||
// Takes a list of checks that run after the database is connected on new databases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a brilliant solution!
Ticket
Description
Fix flake here https://app.circleci.com/pipelines/github/determined-ai/determined/56315/workflows/f5c22283-01d5-4543-a12b-8b5d42fff926/jobs/2624963
by connecting the to the database once, where retries correctly happen
Test Plan
ci passes
Checklist
docs/release-notes/
.See Release Note for details.