Skip to content

Support setting of application_name in database.yml

Stan Hu requested to merge sh-support-application-name into master

By default, the Ruby PostgreSQL driver will specify a fallback_application_name based on the process name and use that as part of the appname connection string. This appname gets sent to PgBouncer, which calls SET application_name every time a connection is used by Rails.

To reduce the load on the database, we want to have the ability to disable the setting of application_name. This can be done by setting this value to a blank string. Note that setting the environment variable PGAPPNAME to a blank string does not do the same thing because an empty environment variable is not defined.

We did this in Omnibus already: gitlab-org/omnibus-gitlab!4808 (merged)

Relates to:

Testing

Before with defaults:

gitlabhq_production=> select application_name from pg_stat_activity order by application_name;
                        application_name                         
-----------------------------------------------------------------
 
 
 
 
 
 
 psql
 puma: cluster worker 0: 10 [gitlab-puma-worker]
 puma: cluster worker 0: 10 [gitlab-puma-worker]
 puma: cluster worker 1: 10 [gitlab-puma-worker]
 puma: cluster worker 1: 10 [gitlab-puma-worker]
 sidekiq 5.2.9 queues:authorize...export_deletion [0 of 25 busy]
 sidekiq 5.2.9 queues:authorize...export_deletion [0 of 25 busy]
 sidekiq 5.2.9 queues:authorize...export_deletion [0 of 25 busy]
 sidekiq 5.2.9 queues:authorize...export_deletion [0 of 25 busy]
 sidekiq 5.2.9 queues:authorize...export_deletion [0 of 25 busy]
 /usr/bin/gitlab-exporter
 /usr/bin/gitlab-exporter
 /usr/bin/gitlab-exporter
(19 rows)

With global.psql.applicationName=""

gitlabhq_production=> select application_name from pg_stat_activity order by application_name;
     application_name     
--------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 psql
 /usr/bin/gitlab-exporter
 /usr/bin/gitlab-exporter
 /usr/bin/gitlab-exporter
(19 rows)

With global.psql.applicationName="mytest"

gitlabhq_production=> select application_name from pg_stat_activity order by application_name;
     application_name     
--------------------------
 
 
 
 
 
 
 
 
 mytest
 mytest
 mytest
 psql
 /usr/bin/gitlab-exporter
 /usr/bin/gitlab-exporter
 /usr/bin/gitlab-exporter
(15 rows)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • Merge Request Title and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Tests added
  • Integration tests added to GitLab QA
  • Equivalent MR/issue for omnibus-gitlab opened
Edited by Stan Hu

Merge request reports