Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Add pooler personality configuration on pgbouncer.ini template #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pgbouncer/templates/_pgbouncer.ini.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ stats_users = {{ $users }}, stats, root, monitor

;;; Pooler personality

pool_mode = {{ .Values.poolMode }}
server_reset_query = DISCARD ALL
;server_reset_query_always = 0
;ignore_startup_parameters = extra_float_digits
;server_check_query = select 1
;server_check_delay = 30
;application_name_add_host = 0
pool_mode = {{ .Values.poolerPersonality.poolMode | default "session" }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

in order to preserve backwards compatibility for chart users that may be doing custom overrides (through a -f overrides.yaml file or by pulling in pgbouncer as a requirements chart), i recommend changing this to use .Values.poolMode if it is in the dictionary. could you change this line to

pool_mode = {{ .Values.poolMode | default .Values.poolerPersonality.poolMode | default "session" }}

Copy link
Author

Choose a reason for hiding this comment

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

Nice trick! I didn't know that one. Thanks for the suggestion!

server_reset_query = {{ .Values.poolerPersonality.serverResetQuery | default "DISCARD ALL" }}
server_reset_query_always = {{ .Values.poolerPersonality.serverResetQueryAlways | default 0 }}
ignore_startup_parameters = {{ .Values.poolerPersonality.ignoreStartupParameters | default "" }}
matth-boise marked this conversation as resolved.
Show resolved Hide resolved
server_check_query = {{ .Values.poolerPersonality.serverCheckQuery | default "SELECT 1;" }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

the default in pgbouncer_1_8_1 is select 1. why did you change it?

Copy link
Author

Choose a reason for hiding this comment

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

You're right, I will update it. I was following pgbouncer's config page

server_check_delay = {{ .Values.poolerPersonality.serverCheckDelay | default 30 }}
application_name_add_host = {{ .Values.poolerPersonality.applicationNameAddHost | default 0 }}

;;; Connection limits

Expand All @@ -77,8 +77,8 @@ default_pool_size = {{ .Values.connectionLimits.defaultPoolSize }}
min_pool_size = {{ .Values.connectionLimits.minPoolSize }}
reserve_pool_size = {{ .Values.connectionLimits.reservePoolSize }}
reserve_pool_timeout = {{ .Values.connectionLimits.reservePoolTimeout }}
;max_db_connections = 0
;max_user_connections = 0
max_db_connections = {{ .Values.connectionLimits.maxDbConnections | default 0 }}
max_user_connections = {{ .Values.connectionLimits.maxUserConnections | default 0 }}
;server_round_robin = 0
;syslog = 0
;syslog_facility = daemon
Expand Down
13 changes: 11 additions & 2 deletions pgbouncer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ nodeAffinity: {} # optionally define nodeAffinity
tolerations: [] # optionally define tolerations
nodeSelector: {} # optionally define nodeSelector

poolMode: session
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you leave the poolMode=session line - but comment it out and add comment? e.g.,
# poolMode: session # please use poolerPersonality.poolMode

Copy link
Author

Choose a reason for hiding this comment

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

Nice idea will do it like that

Copy link
Collaborator

Choose a reason for hiding this comment

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

@angeloskyratzakos it's been a while - sorry! it would be great to get your changes in. could you make this last change - to re-add the poolMode line but commented out?

poolerPersonality:
poolMode: session
# serverResetQuery: "DISCARD ALL"
# serverResetQueryAlways: 0
# ignoreStartupParameters: ""
# serverCheckQuery: "SELECT 1;"
Copy link
Collaborator

Choose a reason for hiding this comment

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

the default in pgbouncer_1_8_1 is select 1. why did you change it?

Copy link
Author

Choose a reason for hiding this comment

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

You are right. I was following the pgbouncer's config

# serverCheckDelay: 30
# applicationNameAddHost: 0

budget:
# PodDisruptionBudget spec.minAvailable
Expand Down Expand Up @@ -51,14 +58,16 @@ settings:
# WHERE usename = p_usename;
# END;
# $$ LANGUAGE plpgsql SECURITY DEFINER;
auth_query: SELECT * FROM pgbouncer.get_auth($1)
auth_query: SELECT * FROM pgbouncer.get_auth($1)

connectionLimits:
maxClientConn: 200
defaultPoolSize: 200
minPoolSize: 15
reservePoolSize: 25
reservePoolTimeout: 5
# maxDbConnections: 0 # zero means unlimited
matth-boise marked this conversation as resolved.
Show resolved Hide resolved
# maxUserConnections: 0 # zero means unlimited
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above (since you didn't add templating for max_user_connections)

Copy link
Author

Choose a reason for hiding this comment

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

I have added for it as well please check line 81


spec:
labels: {}
Expand Down