Skip to content
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

add statement timeout query param for postgres #327

Merged

Conversation

psuresh39
Copy link
Contributor

Adding statement timeout option to postgres driver as a query param

@psuresh39 psuresh39 requested review from dhui and mattes and removed request for dhui January 19, 2020 22:46
@coveralls
Copy link

coveralls commented Jan 19, 2020

Pull Request Test Coverage Report for Build 648

  • 9 of 17 (52.94%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 51.947%

Changes Missing Coverage Covered Lines Changed/Added Lines %
database/postgres/postgres.go 9 17 52.94%
Totals Coverage Status
Change from base Build 646: -0.04%
Covered Lines: 2455
Relevant Lines: 4726

💛 - Coveralls

database/postgres/postgres.go Outdated Show resolved Hide resolved
database/postgres/postgres.go Outdated Show resolved Hide resolved
Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

database/postgres/postgres.go Outdated Show resolved Hide resolved
database/postgres/postgres.go Outdated Show resolved Hide resolved
database/postgres/postgres.go Outdated Show resolved Hide resolved
@@ -25,6 +26,7 @@ func init() {
}

var DefaultMigrationsTable = "schema_migrations"
var DefaultStatementTimeoutMs = 10000 // 10 seconds
Copy link
Member

Choose a reason for hiding this comment

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

Make this a time.Duration as well

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

Copy link
Contributor

Choose a reason for hiding this comment

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

this is actually no longer needed

Copy link
Contributor

@psuresh309 psuresh309 Jan 20, 2020

Choose a reason for hiding this comment

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

In other words, If the caller

  • does not pass any value, we default to 0 (i.e background context)
  • passes an invalid value, we return error from Atoi and abort migration
  • passes valid value, we use it as the timeout value (i.e context with timeout)

@psuresh39 psuresh39 force-pushed the psuresh/postgres-statement-timeout branch from 96f63e8 to 87c2491 Compare January 20, 2020 06:23
@psuresh309
Copy link
Contributor

@dhui Can you give this another read? I would like to merge this soon.

database/postgres/postgres.go Outdated Show resolved Hide resolved
psuresh309
psuresh309 previously approved these changes Jan 21, 2020
database/postgres/postgres.go Outdated Show resolved Hide resolved
database/postgres/postgres.go Outdated Show resolved Hide resolved
if statementTimeoutString != "" {
statementTimeout, err = strconv.Atoi(statementTimeoutString)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

@dhui wondering if we should throw a custom error here instead of the Atoi one, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think we'd lose information w/ a custom error, so it'd be cleaner to wrap the error using multierror.

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Lemme know if you wanna wrap the Atoi() error using multierror and I'll hold off on merging until then.

@psuresh309
Copy link
Contributor

Lemme know if you wanna wrap the Atoi() error using multierror and I'll hold off on merging until then.

not urgent. please go ahead and merge this when you can.

@dhui dhui merged commit f299233 into golang-migrate:master Jan 21, 2020
@psuresh309
Copy link
Contributor

thanks @dhui . When do you plan to make a new release?

@dhui
Copy link
Member

dhui commented Jan 22, 2020

The earliest would be in a week so the change can be tested by people running the master branch. If you'd like to use the change, I'd use the master branch for now and change to the next release when it's available.

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.

5 participants