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

Support statement_timeout in postgresql as a property #1495

Closed
alexanderkjall opened this issue Jun 10, 2019 · 1 comment

Comments

@alexanderkjall
Copy link
Contributor

commented Jun 10, 2019

I'm submitting a ...

  • bug report
  • [ x ] feature request

Describe the issue

Last week we had an incident at work, we had a GUI with a search that hadn't been tested
enough, and the users could request so much data through it so that the database never
finished returning it before the timeout in our loadbalancer terminated the request.

This led to that the users retried the heavy queries, and that led to that all resources on the
database server becoming exhausted.

Postgresql have a statement timeout, so that the database can terminate queries that are
too long running.

It would be convenient if this setting can be exposed as a jdbc url parameter, that way it would
be easy for us to separate the load that is expected to be fast, from the slower things.

Driver Version?

42.2.5

PostgreSQL Version?

Can't seem to find when statement_timeout got introduced, but it seems to be old.

@alexanderkjall alexanderkjall referenced this issue Jun 10, 2019
0 of 1 task complete
@sehrope

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2019

I took a peek at this and the related PR and looks like this is already possible via the generic OPTIONS connection property. It allows you to set arbitrary properties to be set on initialization of the backend server connection. Using a value of -c statement_timeout=500 would have the effect of setting the statement_timeout value for the connection at startup.

See here for the PGJDBC connection property: https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/PGProperty.java#L62

See here for more details on the backend options parameter: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-OPTIONS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.