mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-11 07:22:55 +00:00
Before, compute_ctl didn't have a good registry for what command would run when, depending exclusively on sync code to apply changes. When users have many databases/roles to manage, this step can take a substantial amount of time, breaking assumptions about low (re)start times in other systems. This commit reduces the time compute_ctl takes to restart when changes must be applied, by making all commands more or less blind writes, and applying these commands in an asynchronous context, only waiting for completion once we know the commands have all been sent. Additionally, this reduces time spent by batching per-database operations where previously we would create a new SQL connection for every user-database operation we planned to execute.
30 lines
902 B
SQL
30 lines
902 B
SQL
DO
|
|
$$
|
|
BEGIN
|
|
IF EXISTS(
|
|
SELECT nspname
|
|
FROM pg_catalog.pg_namespace
|
|
WHERE nspname = 'public'
|
|
) AND
|
|
current_setting('server_version_num')::int / 10000 >= 15
|
|
THEN
|
|
IF EXISTS(
|
|
SELECT rolname
|
|
FROM pg_catalog.pg_roles
|
|
WHERE rolname = 'web_access'
|
|
)
|
|
THEN
|
|
GRANT CREATE ON SCHEMA public TO web_access;
|
|
END IF;
|
|
END IF;
|
|
IF EXISTS(
|
|
SELECT nspname
|
|
FROM pg_catalog.pg_namespace
|
|
WHERE nspname = 'public'
|
|
)
|
|
THEN
|
|
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO neon_superuser WITH GRANT OPTION;
|
|
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO neon_superuser WITH GRANT OPTION;
|
|
END IF;
|
|
END
|
|
$$; |