-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Customize query timeouts #249
Comments
I see this as a requirement for #286, I think we need to restrict the clients api usage for that case.
ALTER ROLE webuser SET statement_timeout = 30000
Now another option I've seen is to enforce a
It seems like a safer option, but it relies on a loadable module and it may be inconvenient for the user to setup, so for now maybe we could discuss |
More thoughts on this, I think restricting the statement cost is the best choice, so I've been testing the plan_filter module, originally I thought that it would be enough to setup the roles each with it's own cost in the db without changing PostgREST code but that doesn't work. Say we enable the
When doing a This is because according to the pg docs executing SET ROLE does not cause new configuration values to be set, this only happens at login time. I have an example of this here. So for the |
I think is important to solve this issue, though PostgREST now doesn't directly expose expensive operations users can still do a: GET /tasks?select=*,users{*,tasks{*,users{*,tasks{*,users{*,tasks{*}}}}}} That gives a cost of I propose to have this feature as experimental, also it would only work for postgres instances where you can load the The feature would work by having an
select current_setting('plan_filter.module_loaded') = 'on';`
Also by having this config param, we could have a way to enable more expensive operations such as |
@steve-chavez thanks for the research on this one. I was looking through the postgresql source to try and see if there is a hook for |
For me the ideal solution would still be to integrate with the |
|
@FGRibreau Bear in mind that you can use the My proposal here was more about providing finer grained control and enforcing that the cost limit is present. Now that I think about it, the cost limit on the authenticator might be enough for most cases, I'll see if I can add this idea to our Hardening PostgREST section in the docs. |
Doing a |
Either add a server command line argument to specify the timeout for all connections, or establish it per-user.
For the first option we can make another middleware that composes with
authenticated
:https://github.com/begriffs/postgrest/blob/master/src/PostgREST/Main.hs#L83
For the second option (per user) we can add another column to our auth table and update
setRole
:https://github.com/begriffs/postgrest/blob/master/src/PostgREST/Auth.hs#L56
We'll use the command
SET SESSION STATEMENT_TIMEOUT TO [ms];
/cc @smilliken
The text was updated successfully, but these errors were encountered: