PostgREST timeouts when loading schema cache in multi-tenant environment with large user base and schemas #3774
-
I am facing an issue where PostgREST times out when attempting to load the schema cache in a multi-tenant PostgreSQL environment with approximately 100k schemas. Each schema has a dedicated PostgreSQL user, and PostgREST is configured to impersonate the corresponding user when querying its schema. The timeout occurs around 60 seconds after the request begins I think. I have tried changing up the timeouts with Environment:
CREATE OR REPLACE FUNCTION postgrest.pre_config()
RETURNS void AS $$
SELECT
set_config('pgrst.db_aggregates_enabled', 'true', false);
SELECT
set_config('pgrst.db_schemas', string_agg(nspname, ','), true)
FROM pg_namespace
WHERE nspname LIKE 'workspace_%';
$$ LANGUAGE sql;
PostgREST logs:
Are there recommendations for managing statement timeouts and schema configurations in such a large multi-tenant architecture? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
How did you change that? |
Beta Was this translation helpful? Give feedback.
-
So you are impersonating 100k users, but use the SUPERUSER I really hope this is just your reproducer and not actually happening :D |
Beta Was this translation helpful? Give feedback.
Right, that wouldn't help.
Yes, that's the only way for now.
Also we're now logging the schema cache load time #3779.