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

prevent expensive queries to gtfs-api (PostgREST) #36

Merged
merged 4 commits into from
Nov 21, 2023

Conversation

derhuerst
Copy link
Member

@derhuerst derhuerst commented Nov 9, 2023

This PR contains the commits of #28. Merge that one first.


  • Postgres now uses (via pgbouncer) its own user/role postgrest (before it re-used postgres).
  • postgrest has a "global" limit, so that i can only make queries with costs <100000.
  • By the PostgREST design, we're supposed to be able to set the limit specifically for the anonymous user (web_anon) – PostgREST supposedly has a mechanism to circumvent limitations in PostgreSQL, but it doesn't seem to work.

Do we want to keep the additional 30s query timeout in pgbouncer (8625e41)? Given that it applies to all underlying databases, I'd be careful.

@derhuerst derhuerst force-pushed the gtfs-no-expensive-queries branch from 8625e41 to 4d4bb3b Compare November 13, 2023 13:46
@derhuerst
Copy link
Member Author

postgrest [now] has a "global" limit, so that i can only make queries with costs <100000.

After some testing, I've come to the conclusion that we could easily increase this to ~1m. Depending on the query, with highly varying results, I have measured an estimated cost of ~1m to be roughly equivalent to 0.2s-5s of querying wall clock time.
What do you think?

@derhuerst derhuerst requested a review from hbruch November 13, 2023 19:40
@derhuerst derhuerst changed the title [WIP]: prevent expensive queries to gtfs-api (PostgREST) prevent expensive queries to gtfs-api (PostgREST) Nov 13, 2023
@derhuerst derhuerst force-pushed the gtfs-no-expensive-queries branch 2 times, most recently from 710cea7 to 71b4029 Compare November 17, 2023 15:18
Copy link
Collaborator

@hbruch hbruch left a comment

Choose a reason for hiding this comment

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

LGTM

@derhuerst derhuerst force-pushed the gtfs-no-expensive-queries branch from 71b4029 to d2d0b5a Compare November 21, 2023 19:44
@derhuerst derhuerst merged commit 19cd2cb into main Nov 21, 2023
2 checks passed
@derhuerst derhuerst deleted the gtfs-no-expensive-queries branch November 21, 2023 19:47
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.

2 participants