-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add pgBouncer to QueryApi (#615)
QueryApi has experienced issues with Postgres connections since the introduction of * indexers due to how QueryApi creates these connections through Application level connection pools. Since we can't use one pool for all workers, I've introduced PgBouncer as a Middleware to serve as an additional connection pooler in front of the DB.
- Loading branch information
Showing
5 changed files
with
82 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE ROLE pgbouncer LOGIN; | ||
ALTER ROLE pgbouncer WITH PASSWORD 'pgbouncer'; | ||
CREATE OR REPLACE FUNCTION public.user_lookup(in i_username text, out uname text, out phash text) | ||
RETURNS record AS $$ | ||
BEGIN | ||
SELECT usename, passwd FROM pg_catalog.pg_shadow | ||
WHERE usename = i_username INTO uname, phash; | ||
RETURN; | ||
END; | ||
$$ LANGUAGE plpgsql SECURITY DEFINER; | ||
REVOKE ALL ON FUNCTION public.user_lookup(text) FROM public; | ||
GRANT EXECUTE ON FUNCTION public.user_lookup(text) TO pgbouncer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters