Omnibus not starting up PostgreSQL in time to do migration

I'm running into the same issue as in #2233 (closed).

I still have this problem upgrading the omnibus package to 9.3.0-ce.0 (Ubuntu 14.04).

Funny thing is, when I try to fix the problem with gitlab-ctl pg_upgrade it actually says specifically that it is stopping the database server before upgrade:

ncgalopp@ncgalopp-nuc:/var/opt/gitlab/postgresql $ sudo gitlab-ctl pg-upgrade
Checking for an omnibus managed postgresql: OK
Checking if we already upgraded: NOT OK
Checking for a newer version of PostgreSQL to install: OK
Upgrading PostgreSQL to 9.6.3
Checking if PostgreSQL bin files are symlinked to the expected location: OK
Toggling deploy page:cp /opt/gitlab/embedded/service/gitlab-rails/public/deploy.html /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: down: logrotate: 0s, normally up
ok: down: mailroom: 1s, normally up
ok: down: sidekiq: 0s, normally up
Toggling services: OK
Waiting 30 seconds to ensure tasks complete before PostgreSQL upgrade
Please hit Ctrl-C now if you want to cancel the upgrade
Stopping the database:ok: down: postgresql: 0s, normally up
Stopping the database: OK
Update the symlinks: OK
Creating temporary data directory: OK
Initializing the new database: OK
Upgrading the data: OK
Move the old data directory out of the way: OK
Rename the new data directory: OK
Upgrade is complete, doing post configuration steps
Running reconfigure:Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - package (0.0.0)
  - gitlab (0.0.1)
  - runit (0.14.2)
  - registry (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default
  * directory[/etc/gitlab] action create (up to date)
init (upstart 1.12.1)
  Converging 465 resources
  * directory[/etc/gitlab] action create (up to date)
  * directory[Create /var/opt/gitlab] action create (up to date)
  * directory[/opt/gitlab/embedded/etc] action create (up to date)
  * template[/opt/gitlab/embedded/etc/gitconfig] action create (up to date)
Recipe: gitlab::web-server
  * group[Webserver user and group] action create (up to date)
  * user[Webserver user and group] action create (up to date)
Recipe: gitlab::users
  * directory[/var/opt/gitlab] action create (up to date)
  * group[GitLab user and group] action create (up to date)
  * user[GitLab user and group] action create (up to date)
  * template[/var/opt/gitlab/.gitconfig] action create (up to date)
Recipe: gitlab::gitlab-shell
  * ruby_block[directory resource: /var/opt/gitlab/git-data] action run (skipped due to not_if)
  * ruby_block[directory resource: /var/opt/gitlab/git-data/repositories] action run (skipped due to not_if)
  * ruby_block[directory resource: /var/opt/gitlab/.ssh] action run (skipped due to not_if)
  * directory[/var/log/gitlab/gitlab-shell/] action create (up to date)
  * directory[/var/opt/gitlab/gitlab-shell] action create (up to date)
  * templatesymlink[Create a config.yml and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-shell/config.yml] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-shell/config.yml to /var/opt/gitlab/gitlab-shell/config.yml] action create (up to date)
     (up to date)
  * link[/opt/gitlab/embedded/service/gitlab-shell/.gitlab_shell_secret] action create (up to date)
  * execute[/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions] action run
    - execute /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-keys check-permissions
  * bash[Set proper security context on ssh files for selinux] action run (skipped due to only_if)
Recipe: gitlab::gitlab-rails
  * directory[/var/log/gitlab] action create (up to date)
  * ruby_block[directory resource: /var/opt/gitlab/gitlab-rails/shared] action run (skipped due to not_if)
  * ruby_block[directory resource: /var/opt/gitlab/gitlab-rails/shared/artifacts] action run (skipped due to not_if)
  * ruby_block[directory resource: /var/opt/gitlab/gitlab-rails/shared/lfs-objects] action run (skipped due to not_if)
  * ruby_block[directory resource: /var/opt/gitlab/gitlab-rails/uploads] action run (skipped due to not_if)
  * ruby_block[directory resource: /var/opt/gitlab/gitlab-ci/builds] action run (skipped due to not_if)
  * ruby_block[directory resource: /var/opt/gitlab/gitlab-rails/shared/pages] action run (skipped due to not_if)
  * directory[create /var/opt/gitlab/gitlab-rails/etc] action create (up to date)
  * directory[create /opt/gitlab/etc/gitlab-rails] action create (up to date)
  * directory[create /var/opt/gitlab/gitlab-rails/working] action create (up to date)
  * directory[create /var/opt/gitlab/gitlab-rails/tmp] action create (up to date)
  * directory[create /var/opt/gitlab/gitlab-rails/upgrade-status] action create (up to date)
  * directory[create /var/log/gitlab/gitlab-rails] action create (up to date)
  * directory[/var/opt/gitlab/backups] action create (up to date)
  * directory[/var/opt/gitlab/gitlab-rails] action create (up to date)
  * directory[/var/opt/gitlab/gitlab-ci] action create (up to date)
  * template[/opt/gitlab/etc/gitlab-rails/gitlab-rails-rc] action create (up to date)
  * file[/opt/gitlab/embedded/service/gitlab-rails/.secret] action delete (up to date)
  * file[/var/opt/gitlab/gitlab-rails/etc/secret] action delete (up to date)
  * templatesymlink[Create a database.yml and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-rails/etc/database.yml] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/database.yml to /var/opt/gitlab/gitlab-rails/etc/database.yml] action create (up to date)
     (up to date)
  * templatesymlink[Create a secrets.yml and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-rails/etc/secrets.yml] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/secrets.yml to /var/opt/gitlab/gitlab-rails/etc/secrets.yml] action create (up to date)
     (up to date)
  * templatesymlink[Create a resque.yml and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-rails/etc/resque.yml] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/resque.yml to /var/opt/gitlab/gitlab-rails/etc/resque.yml] action create (up to date)
     (up to date)
  * templatesymlink[Create a aws.yml and create a symlink to Rails root] action delete
    * template[/var/opt/gitlab/gitlab-rails/etc/aws.yml] action delete (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/aws.yml to /var/opt/gitlab/gitlab-rails/etc/aws.yml] action delete (up to date)
     (up to date)
  * templatesymlink[Create a smtp_settings.rb and create a symlink to Rails root] action delete
    * template[/var/opt/gitlab/gitlab-rails/etc/smtp_settings.rb] action delete (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb to /var/opt/gitlab/gitlab-rails/etc/smtp_settings.rb] action delete (up to date)
     (up to date)
  * templatesymlink[Create a gitlab.yml and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-rails/etc/gitlab.yml] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml to /var/opt/gitlab/gitlab-rails/etc/gitlab.yml] action create (up to date)
     (up to date)
  * templatesymlink[Create a rack_attack.rb and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-rails/etc/rack_attack.rb] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/initializers/rack_attack.rb to /var/opt/gitlab/gitlab-rails/etc/rack_attack.rb] action create (up to date)
     (up to date)
  * templatesymlink[Create a gitlab_workhorse_secret and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret to /var/opt/gitlab/gitlab-rails/etc/gitlab_workhorse_secret] action create (up to date)
     (up to date)
  * templatesymlink[Create a gitlab_shell_secret and create a symlink to Rails root] action create
    * template[/var/opt/gitlab/gitlab-rails/etc/gitlab_shell_secret] action create (up to date)
    * link[Link /opt/gitlab/embedded/service/gitlab-rails/.gitlab_shell_secret to /var/opt/gitlab/gitlab-rails/etc/gitlab_shell_secret] action create (up to date)
     (up to date)
  * directory[/opt/gitlab/etc/gitlab-rails/env] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/HOME] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/RAILS_ENV] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/LD_PRELOAD] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/SIDEKIQ_MEMORY_KILLER_MAX_RSS] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/BUNDLE_GEMFILE] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/PATH] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/ICU_DATA] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/PYTHONPATH] action create (up to date)
  * file[/opt/gitlab/etc/gitlab-rails/env/EXECJS_RUNTIME] action create (up to date)
  * link[/opt/gitlab/embedded/service/gitlab-rails/tmp] action create (up to date)
  * link[/opt/gitlab/embedded/service/gitlab-rails/public/uploads] action create (up to date)
  * link[/opt/gitlab/embedded/service/gitlab-rails/log] action create (up to date)
  * link[/var/log/gitlab/gitlab-rails/sidekiq.log] action create (skipped due to not_if)
  * file[/opt/gitlab/embedded/service/gitlab-rails/db/schema.rb] action create (up to date)
  * remote_file[/var/opt/gitlab/gitlab-rails/VERSION] action create (up to date)
  * remote_file[/var/opt/gitlab/gitlab-rails/REVISION] action create (up to date)
  * file[/var/opt/gitlab/gitlab-rails/RUBY_VERSION] action create (up to date)
  * execute[chown -R root:root /opt/gitlab/embedded/service/gitlab-rails/public] action run
    - execute chown -R root:root /opt/gitlab/embedded/service/gitlab-rails/public
  * execute[clear the gitlab-rails cache] action nothing (skipped due to action :nothing)
  * file[/var/opt/gitlab/gitlab-rails/config.ru] action delete (up to date)
Recipe: gitlab::add_trusted_certs
  * directory[/etc/gitlab/trusted-certs] action create (up to date)
  * directory[/opt/gitlab/embedded/ssl/certs] action create (up to date)
  * file[/opt/gitlab/embedded/ssl/certs/README] action create (up to date)
  * ruby_block[Move existing certs and link to /opt/gitlab/embedded/ssl/certs] action run (skipped due to only_if)
Recipe: gitlab::default
  * service[create a temporary unicorn service] action nothing (skipped due to action :nothing)
  * service[create a temporary sidekiq service] action nothing (skipped due to action :nothing)
  * service[create a temporary mailroom service] action nothing (skipped due to action :nothing)
Recipe: runit::upstart
  * cookbook_file[/etc/init/gitlab-runsvdir.conf] action create (up to date)
  * execute[initctl reload-configuration] action run
    - execute initctl reload-configuration
  * execute[initctl status gitlab-runsvdir] action run
    [execute] gitlab-runsvdir start/running, process 1009
    - execute initctl status gitlab-runsvdir
  * execute[initctl start gitlab-runsvdir] action run (skipped due to only_if)
Recipe: gitlab::redis
  * group[user and group for redis] action create (up to date)
  * user[user and group for redis] action create (up to date)
  * group[Socket group] action create (up to date)
  * directory[/var/opt/gitlab/redis] action create (up to date)
  * directory[/var/log/gitlab/redis] action create (up to date)
  * template[/var/opt/gitlab/redis/redis.conf] action create (up to date)
  * directory[/opt/gitlab/sv/redis] action create (up to date)
  * directory[/opt/gitlab/sv/redis/log] action create (up to date)
  * directory[/opt/gitlab/sv/redis/log/main] action create (up to date)
  * template[/opt/gitlab/sv/redis/run] action create (up to date)
  * template[/opt/gitlab/sv/redis/log/run] action create (up to date)
  * template[/var/log/gitlab/redis/config] action create (up to date)
  * ruby_block[reload redis svlogd configuration] action nothing (skipped due to action :nothing)
  * file[/opt/gitlab/sv/redis/down] action delete (up to date)
  * link[/opt/gitlab/init/redis] action create (up to date)
  * link[/opt/gitlab/service/redis] action create (up to date)
  * ruby_block[supervise_redis_sleep] action run (skipped due to not_if)
  * directory[/opt/gitlab/sv/redis/supervise] action create (up to date)
  * directory[/opt/gitlab/sv/redis/log/supervise] action create (up to date)
  * file[/opt/gitlab/sv/redis/supervise/ok] action touch (skipped due to not_if)
  * file[/opt/gitlab/sv/redis/log/supervise/ok] action touch (skipped due to not_if)
  * file[/opt/gitlab/sv/redis/supervise/control] action touch (skipped due to not_if)
  * file[/opt/gitlab/sv/redis/log/supervise/control] action touch (skipped due to not_if)
  * service[redis] action nothing (skipped due to action :nothing)
Recipe: gitlab::postgresql_user
  * group[Postgresql user and group] action create (up to date)
  * user[Postgresql user and group] action create (up to date)
Recipe: gitlab::postgresql
  * directory[/var/opt/gitlab/postgresql] action create (up to date)
  * directory[/var/opt/gitlab/postgresql/data] action create (up to date)
  * directory[/var/log/gitlab/postgresql] action create (up to date)
  * link[/var/opt/gitlab/postgresql/data] action create (skipped due to not_if)
  * file[/var/opt/gitlab/postgresql/.profile] action create (up to date)
  * directory[create /etc/sysctl.d for kernel.shmmax] action create (up to date)
  * file[create /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmmax.conf kernel.shmmax] action create (up to date)
  * link[/etc/sysctl.d/90-omnibus-gitlab-kernel.shmmax.conf] action create (up to date)
  * file[delete /etc/sysctl.d/90-postgresql.conf kernel.shmmax] action delete (skipped due to only_if)
  * file[delete /etc/sysctl.d/90-unicorn.conf kernel.shmmax] action delete (skipped due to only_if)
  * file[delete /opt/gitlab/embedded/etc/90-omnibus-gitlab.conf kernel.shmmax] action delete (skipped due to only_if)
  * file[delete /etc/sysctl.d/90-omnibus-gitlab.conf kernel.shmmax] action delete (skipped due to only_if)
  * execute[load sysctl conf kernel.shmmax] action nothing (skipped due to action :nothing)
  * directory[create /etc/sysctl.d for kernel.shmall] action create (up to date)
  * file[create /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmall.conf kernel.shmall] action create (up to date)
  * link[/etc/sysctl.d/90-omnibus-gitlab-kernel.shmall.conf] action create (up to date)
  * file[delete /etc/sysctl.d/90-postgresql.conf kernel.shmall] action delete (skipped due to only_if)
  * file[delete /etc/sysctl.d/90-unicorn.conf kernel.shmall] action delete (skipped due to only_if)
  * file[delete /opt/gitlab/embedded/etc/90-omnibus-gitlab.conf kernel.shmall] action delete (skipped due to only_if)
  * file[delete /etc/sysctl.d/90-omnibus-gitlab.conf kernel.shmall] action delete (skipped due to only_if)
  * execute[load sysctl conf kernel.shmall] action nothing (skipped due to action :nothing)
  * directory[create /etc/sysctl.d for kernel.sem] action create (up to date)
  * file[create /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf kernel.sem] action create (up to date)
  * link[/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf] action create (up to date)
  * file[delete /etc/sysctl.d/90-postgresql.conf kernel.sem] action delete (skipped due to only_if)
  * file[delete /etc/sysctl.d/90-unicorn.conf kernel.sem] action delete (skipped due to only_if)
  * file[delete /opt/gitlab/embedded/etc/90-omnibus-gitlab.conf kernel.sem] action delete (skipped due to only_if)
  * file[delete /etc/sysctl.d/90-omnibus-gitlab.conf kernel.sem] action delete (skipped due to only_if)
  * execute[load sysctl conf kernel.sem] action nothing (skipped due to action :nothing)
  * execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] action run (skipped due to not_if)
  * template[/var/opt/gitlab/postgresql/data/postgresql.conf] action create
    - update content in file /var/opt/gitlab/postgresql/data/postgresql.conf from 3733db to 692a6d
    --- /var/opt/gitlab/postgresql/data/postgresql.conf 2017-06-22 10:53:05.220077540 -0700
    +++ /var/opt/gitlab/postgresql/data/.chef-postgresql.conf20170622-25881-11rlojc     2017-06-22 10:53:24.807991006 -0700
    @@ -1,3 +1,7 @@
    +# This file is managed by gitlab-ctl. Manual changes will be
    +# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
    +# and run `sudo gitlab-ctl reconfigure`.
    +
     # -----------------------------
     # PostgreSQL configuration file
     # -----------------------------
    @@ -27,7 +31,7 @@
     # Memory units:  kB = kilobytes        Time units:  ms  = milliseconds
     #                MB = megabytes                     s   = seconds
     #                GB = gigabytes                     min = minutes
    -#                TB = terabytes                     h   = hours
    +#                                                   h   = hours
     #                                                   d   = days


    @@ -38,16 +42,16 @@
     # The default values of these variables are driven from the -D command-line
     # option or PGDATA environment variable, represented here as ConfigDir.

    -#data_directory = 'ConfigDir'              # use data in another directory
    -                                   # (change requires restart)
    -#hba_file = 'ConfigDir/pg_hba.conf'        # host-based authentication file
    -                                   # (change requires restart)
    -#ident_file = 'ConfigDir/pg_ident.conf'    # ident configuration file
    -                                   # (change requires restart)
    +#data_directory = 'ConfigDir'   # use data in another directory
    +          # (change requires restart)
    +#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
    +          # (change requires restart)
    +#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
    +          # (change requires restart)

     # If external_pid_file is not explicitly set, no extra PID file is written.
    -#external_pid_file = ''                    # write an extra PID file
    -                                   # (change requires restart)
    +#external_pid_file = '(none)'   # write an extra PID file
    +          # (change requires restart)


     #------------------------------------------------------------------------------
    @@ -56,52 +60,48 @@

     # - Connection Settings -

    -#listen_addresses = 'localhost'            # what IP address(es) to listen on;
    -                                   # comma-separated list of addresses;
    -                                   # defaults to 'localhost'; use '*' for all
    -                                   # (change requires restart)
    -#port = 5432                               # (change requires restart)
    -max_connections = 100                      # (change requires restart)
    -#superuser_reserved_connections = 3        # (change requires restart)
    -#unix_socket_directories = '/tmp'  # comma-separated list of directories
    -                                   # (change requires restart)
    -#unix_socket_group = ''                    # (change requires restart)
    -#unix_socket_permissions = 0777            # begin with 0 to use octal notation
    -                                   # (change requires restart)
    -#bonjour = off                             # advertise server via Bonjour
    -                                   # (change requires restart)
    -#bonjour_name = ''                 # defaults to the computer name
    -                                   # (change requires restart)
    +listen_addresses = ''    # what IP address(es) to listen on;
    +          # comma-separated list of addresses;
    +          # defaults to 'localhost', '*' = all
    +          # (change requires restart)
    +port = 5432        # (change requires restart)
    +max_connections = 200      # (change requires restart)
    +# Note:  Increasing max_connections costs ~400 bytes of shared memory per
    +# connection slot, plus lock space (see max_locks_per_transaction).
    +#superuser_reserved_connections = 3 # (change requires restart)
    +unix_socket_directories = '/var/opt/gitlab/postgresql'   # (change requires restart)
    +#unix_socket_group = ''     # (change requires restart)
    +#unix_socket_permissions = 0777   # begin with 0 to use octal notation
    +          # (change requires restart)
    +#bonjour = off        # advertise server via Bonjour
    +          # (change requires restart)
    +#bonjour_name = ''      # defaults to the computer name
    +          # (change requires restart)

     # - Security and Authentication -

    -#authentication_timeout = 1min             # 1s-600s
    -#ssl = off                         # (change requires restart)
    -#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
    -                                   # (change requires restart)
    -#ssl_prefer_server_ciphers = on            # (change requires restart)
    -#ssl_ecdh_curve = 'prime256v1'             # (change requires restart)
    -#ssl_cert_file = 'server.crt'              # (change requires restart)
    -#ssl_key_file = 'server.key'               # (change requires restart)
    -#ssl_ca_file = ''                  # (change requires restart)
    -#ssl_crl_file = ''                 # (change requires restart)
    +#authentication_timeout = 1min    # 1s-600s
    +#ssl = off        # (change requires restart)
    +#ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH'  # allowed SSL ciphers
    +          # (change requires restart)
    +#ssl_renegotiation_limit = 512MB  # amount of data between renegotiations
     #password_encryption = on
     #db_user_namespace = off
    -#row_security = on

    -# GSSAPI using Kerberos
    +# Kerberos and GSSAPI
     #krb_server_keyfile = ''
    +#krb_srvname = 'postgres'   # (Kerberos only)
     #krb_caseins_users = off

     # - TCP Keepalives -
     # see "man 7 tcp" for details

    -#tcp_keepalives_idle = 0           # TCP_KEEPIDLE, in seconds;
    -                                   # 0 selects the system default
    -#tcp_keepalives_interval = 0               # TCP_KEEPINTVL, in seconds;
    -                                   # 0 selects the system default
    -#tcp_keepalives_count = 0          # TCP_KEEPCNT;
    -                                   # 0 selects the system default
    +#tcp_keepalives_idle = 0    # TCP_KEEPIDLE, in seconds;
    +          # 0 selects the system default
    +#tcp_keepalives_interval = 0    # TCP_KEEPINTVL, in seconds;
    +          # 0 selects the system default
    +#tcp_keepalives_count = 0   # TCP_KEEPCNT;
    +          # 0 selects the system default


     #------------------------------------------------------------------------------
    @@ -110,62 +110,40 @@

     # - Memory -

    -shared_buffers = 128MB                     # min 128kB
    -                                   # (change requires restart)
    -#huge_pages = try                  # on, off, or try
    -                                   # (change requires restart)
    -#temp_buffers = 8MB                        # min 800kB
    -#max_prepared_transactions = 0             # zero disables the feature
    -                                   # (change requires restart)
    -# Caution: it is not advisable to set max_prepared_transactions nonzero unless
    -# you actively intend to use prepared transactions.
    -#work_mem = 4MB                            # min 64kB
    -#maintenance_work_mem = 64MB               # min 1MB
    -#replacement_sort_tuples = 150000  # limits use of replacement selection sort
    -#autovacuum_work_mem = -1          # min 1MB, or -1 to use maintenance_work_mem
    -#max_stack_depth = 2MB                     # min 100kB
    -dynamic_shared_memory_type = posix # the default is the first option
    -                                   # supported by the operating system:
    -                                   #   posix
    -                                   #   sysv
    -                                   #   windows
    -                                   #   mmap
    -                                   # use none to disable dynamic shared memory
    +shared_buffers = 1971MB # min 128kB
    +          # (change requires restart)
    +#temp_buffers = 8MB     # min 800kB
    +#max_prepared_transactions = 0    # zero disables the feature
    +          # (change requires restart)
    +# Note:  Increasing max_prepared_transactions costs ~600 bytes of shared memory
    +# per transaction slot, plus lock space (see max_locks_per_transaction).
    +# It is not advisable to set max_prepared_transactions nonzero unless you
    +# actively intend to use prepared transactions.
    +#max_stack_depth = 2MB      # min 100kB

    -# - Disk -
    -
    -#temp_file_limit = -1                      # limits per-process temp file space
    -                                   # in kB, or -1 for no limit
    -
     # - Kernel Resource Usage -

    -#max_files_per_process = 1000              # min 25
    -                                   # (change requires restart)
    -#shared_preload_libraries = ''             # (change requires restart)
    +#max_files_per_process = 1000   # min 25
    +          # (change requires restart)
    +shared_preload_libraries = ''    # (change requires restart)

     # - Cost-Based Vacuum Delay -

    -#vacuum_cost_delay = 0                     # 0-100 milliseconds
    -#vacuum_cost_page_hit = 1          # 0-10000 credits
    -#vacuum_cost_page_miss = 10                # 0-10000 credits
    -#vacuum_cost_page_dirty = 20               # 0-10000 credits
    -#vacuum_cost_limit = 200           # 1-10000 credits
    +#vacuum_cost_delay = 0ms    # 0-100 milliseconds
    +#vacuum_cost_page_hit = 1   # 0-10000 credits
    +#vacuum_cost_page_miss = 10   # 0-10000 credits
    +#vacuum_cost_page_dirty = 20    # 0-10000 credits
    +#vacuum_cost_limit = 200    # 1-10000 credits

     # - Background Writer -

    -#bgwriter_delay = 200ms                    # 10-10000ms between rounds
    -#bgwriter_lru_maxpages = 100               # 0-1000 max buffers written/round
    -#bgwriter_lru_multiplier = 2.0             # 0-10.0 multiplier on buffers scanned/round
    -#bgwriter_flush_after = 512kB              # measured in pages, 0 disables
    +#bgwriter_delay = 200ms     # 10-10000ms between rounds
    +#bgwriter_lru_maxpages = 100    # 0-1000 max buffers written/round
    +#bgwriter_lru_multiplier = 2.0    # 0-10.0 multipler on buffers scanned/round

     # - Asynchronous Behavior -

    -#effective_io_concurrency = 1              # 1-1000; 0 disables prefetching
    -#max_worker_processes = 8          # (change requires restart)
    -#max_parallel_workers_per_gather = 0       # taken from max_worker_processes
    -#old_snapshot_threshold = -1               # 1min-60d; -1 disables; 0 is immediate
    -                                   # (change requires restart)
    -#backend_flush_after = 0           # measured in pages, 0 disables
    +#effective_io_concurrency = 1   # 1-1000. 0 disables prefetching


     #------------------------------------------------------------------------------
    @@ -174,103 +152,62 @@

     # - Settings -

    -#wal_level = minimal                       # minimal, replica, or logical
    -                                   # (change requires restart)
    -#fsync = on                                # flush data to disk for crash safety
    -                                           # (turning this off can cause
    -                                           # unrecoverable data corruption)
    -#synchronous_commit = on           # synchronization level;
    -                                   # off, local, remote_write, remote_apply, or on
    -#wal_sync_method = fsync           # the default is the first option
    -                                   # supported by the operating system:
    -                                   #   open_datasync
    -                                   #   fdatasync (default on Linux)
    -                                   #   fsync
    -                                   #   fsync_writethrough
    -                                   #   open_sync
    -#full_page_writes = on                     # recover from partial page writes
    -#wal_compression = off                     # enable compression of full-page writes
    -#wal_log_hints = off                       # also do full page writes of non-critical updates
    -                                   # (change requires restart)
    -#wal_buffers = -1                  # min 32kB, -1 sets based on shared_buffers
    -                                   # (change requires restart)
    -#wal_writer_delay = 200ms          # 1-10000 milliseconds
    -#wal_writer_flush_after = 1MB              # measured in pages, 0 disables
    +wal_level = minimal
    +          # (change requires restart)
    +#fsync = on       # turns forced synchronization on or off
    +#wal_sync_method = fsync    # the default is the first option
    +          # supported by the operating system:
    +          #   open_datasync
    +          #   fdatasync (default on Linux)
    +          #   fsync
    +          #   fsync_writethrough
    +          #   open_sync
    +#full_page_writes = on      # recover from partial page writes
    +wal_buffers = -1 # -1     # min 32kB, -1 sets based on shared_buffers
    +          # (change requires restart)
    +#wal_writer_delay = 200ms   # 1-10000 milliseconds

    -#commit_delay = 0                  # range 0-100000, in microseconds
    -#commit_siblings = 5                       # range 1-1000
    +#commit_delay = 0     # range 0-100000, in microseconds
    +#commit_siblings = 5      # range 1-1000

    -# - Checkpoints -
    +min_wal_size = 80MB
    +max_wal_size = 1GB

    -#checkpoint_timeout = 5min         # range 30s-1d
    -#max_wal_size = 1GB
    -#min_wal_size = 80MB
    -#checkpoint_completion_target = 0.5        # checkpoint target duration, 0.0 - 1.0
    -#checkpoint_flush_after = 256kB            # measured in pages, 0 disables
    -#checkpoint_warning = 30s          # 0 disables
    +# The number of replication slots to reserve.
    +max_replication_slots = 0

    +
     # - Archiving -

    -#archive_mode = off                # enables archiving; off, on, or always
    -                           # (change requires restart)
    -#archive_command = ''              # command to use to archive a logfile segment
    -                           # placeholders: %p = path of file to archive
    -                           #               %f = file name only
    -                           # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
    -#archive_timeout = 0               # force a logfile segment switch after this
    -                           # number of seconds; 0 disables
    +archive_mode = off   # allows archiving to be done
    +        # (change requires restart, also requires 'wal_level' of 'hot_standby' OR 'replica')

    -
     #------------------------------------------------------------------------------
     # REPLICATION
     #------------------------------------------------------------------------------

    -# - Sending Server(s) -
    -
    -# Set these on the master and on any standby that will send replication data.
    -
    -#max_wal_senders = 0               # max number of walsender processes
    -                           # (change requires restart)
    -#wal_keep_segments = 0             # in logfile segments, 16MB each; 0 disables
    -#wal_sender_timeout = 60s  # in milliseconds; 0 disables
    -
    -#max_replication_slots = 0 # max number of replication slots
    -                           # (change requires restart)
    -#track_commit_timestamp = off      # collect timestamp of transaction commit
    -                           # (change requires restart)
    -
     # - Master Server -

    -# These settings are ignored on a standby server.
    +# These settings are ignored on a standby server

    -#synchronous_standby_names = ''    # standby servers that provide sync rep
    -                           # number of sync standbys and comma-separated list of application_name
    -                           # from standby(s); '*' = all
    -#vacuum_defer_cleanup_age = 0      # number of xacts by which cleanup is delayed
    +max_wal_senders = 0
    +        # (change requires restart)
    +#wal_sender_delay = 1s    # walsender cycle time, 1-10000 milliseconds
    +#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
    +#replication_timeout = 60s  # in milliseconds; 0 disables
    +#synchronous_standby_names = '' # standby servers that provide sync rep
    +        # comma-separated list of application_name
    +        # from standby(s); '*' = all

     # - Standby Servers -

    -# These settings are ignored on a master server.
    +# These settings are ignored on a master server

    -#hot_standby = off                 # "on" allows queries during recovery
    -                                   # (change requires restart)
    -#max_standby_archive_delay = 30s   # max delay before canceling queries
    -                                   # when reading WAL from archive;
    -                                   # -1 allows indefinite delay
    -#max_standby_streaming_delay = 30s # max delay before canceling queries
    -                                   # when reading streaming WAL;
    -                                   # -1 allows indefinite delay
    -#wal_receiver_status_interval = 10s        # send replies at least this often
    -                                   # 0 disables
    -#hot_standby_feedback = off                # send info from standby to prevent
    -                                   # query conflicts
    -#wal_receiver_timeout = 60s                # time that receiver waits for
    -                                   # communication from master
    -                                   # in milliseconds; 0 disables
    -#wal_retrieve_retry_interval = 5s  # time to wait before retrying to
    -                                   # retrieve WAL after a failed attempt
    +hot_standby = off
    +          # (change requires restart)
    +#wal_receiver_status_interval = 10s # send replies at least this often
    +          # 0 disables

    -
     #------------------------------------------------------------------------------
     # QUERY TUNING
     #------------------------------------------------------------------------------
    @@ -281,7 +218,6 @@
     #enable_hashagg = on
     #enable_hashjoin = on
     #enable_indexscan = on
    -#enable_indexonlyscan = on
     #enable_material = on
     #enable_mergejoin = on
     #enable_nestloop = on
    @@ -291,35 +227,28 @@

     # - Planner Cost Constants -

    -#seq_page_cost = 1.0                       # measured on an arbitrary scale
    -#random_page_cost = 4.0                    # same scale as above
    -#cpu_tuple_cost = 0.01                     # same scale as above
    -#cpu_index_tuple_cost = 0.005              # same scale as above
    -#cpu_operator_cost = 0.0025                # same scale as above
    -#parallel_tuple_cost = 0.1         # same scale as above
    -#parallel_setup_cost = 1000.0      # same scale as above
    -#min_parallel_relation_size = 8MB
    -#effective_cache_size = 4GB
    +#cpu_tuple_cost = 0.01      # same scale as above
    +#cpu_index_tuple_cost = 0.005   # same scale as above
    +#cpu_operator_cost = 0.0025   # same scale as above

     # - Genetic Query Optimizer -

     #geqo = on
     #geqo_threshold = 12
    -#geqo_effort = 5                   # range 1-10
    -#geqo_pool_size = 0                        # selects default based on effort
    -#geqo_generations = 0                      # selects default based on effort
    -#geqo_selection_bias = 2.0         # range 1.5-2.0
    -#geqo_seed = 0.0                   # range 0.0-1.0
    +#geqo_effort = 5      # range 1-10
    +#geqo_pool_size = 0     # selects default based on effort
    +#geqo_generations = 0     # selects default based on effort
    +#geqo_selection_bias = 2.0    # range 1.5-2.0
    +#geqo_seed = 0.0      # range 0.0-1.0

     # - Other Planner Options -

    -#default_statistics_target = 100   # range 1-10000
    -#constraint_exclusion = partition  # on, off, or partition
    -#cursor_tuple_fraction = 0.1               # range 0.0-1.0
    +#default_statistics_target = 100  # range 1-10000
    +#constraint_exclusion = partition # on, off, or partition
    +#cursor_tuple_fraction = 0.1    # range 0.0-1.0
     #from_collapse_limit = 8
    -#join_collapse_limit = 8           # 1 disables collapsing of explicit
    -                                   # JOIN clauses
    -#force_parallel_mode = off
    +#join_collapse_limit = 8    # 1 disables collapsing of explicit
    +          # JOIN clauses


     #------------------------------------------------------------------------------
    @@ -328,143 +257,105 @@

     # - Where to Log -

    -#log_destination = 'stderr'                # Valid values are combinations of
    -                                   # stderr, csvlog, syslog, and eventlog,
    -                                   # depending on platform.  csvlog
    -                                   # requires logging_collector to be on.
    +#log_destination = 'stderr'   # Valid values are combinations of
    +          # stderr, csvlog, syslog, and eventlog,
    +          # depending on platform.  csvlog
    +          # requires logging_collector to be on.

     # This is used when logging to stderr:
    -#logging_collector = off           # Enable capturing of stderr and csvlog
    -                                   # into log files. Required to be on for
    -                                   # csvlogs.
    -                                   # (change requires restart)
    +#logging_collector = off    # Enable capturing of stderr and csvlog
    +          # into log files. Required to be on for
    +          # csvlogs.
    +          # (change requires restart)

     # These are only used if logging_collector is on:
    -#log_directory = 'pg_log'          # directory where log files are written,
    -                                   # can be absolute or relative to PGDATA
    -#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'   # log file name pattern,
    -                                   # can include strftime() escapes
    -#log_file_mode = 0600                      # creation mode for log files,
    -                                   # begin with 0 to use octal notation
    -#log_truncate_on_rotation = off            # If on, an existing log file with the
    -                                   # same name as the new log file will be
    -                                   # truncated rather than appended to.
    -                                   # But such truncation only occurs on
    -                                   # time-driven rotation, not on restarts
    -                                   # or size-driven rotation.  Default is
    -                                   # off, meaning append to existing files
    -                                   # in all cases.
    -#log_rotation_age = 1d                     # Automatic rotation of logfiles will
    -                                   # happen after that time.  0 disables.
    -#log_rotation_size = 10MB          # Automatic rotation of logfiles will
    -                                   # happen after that much log output.
    -                                   # 0 disables.
    +#log_directory = 'pg_log'   # directory where log files are written,
    +          # can be absolute or relative to PGDATA
    +#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'  # log file name pattern,
    +          # can include strftime() escapes
    +#log_file_mode = 0600     # creation mode for log files,
    +          # begin with 0 to use octal notation
    +#log_truncate_on_rotation = off   # If on, an existing log file with the
    +          # same name as the new log file will be
    +          # truncated rather than appended to.
    +          # But such truncation only occurs on
    +          # time-driven rotation, not on restarts
    +          # or size-driven rotation.  Default is
    +          # off, meaning append to existing files
    +          # in all cases.
    +#log_rotation_age = 1d      # Automatic rotation of logfiles will
    +          # happen after that time.  0 disables.
    +#log_rotation_size = 10MB   # Automatic rotation of logfiles will
    +          # happen after that much log output.
    +          # 0 disables.

     # These are relevant when logging to syslog:
     #syslog_facility = 'LOCAL0'
     #syslog_ident = 'postgres'
    -#syslog_sequence_numbers = on
    -#syslog_split_messages = on

    -# This is only relevant when logging to eventlog (win32):
    -#event_source = 'PostgreSQL'
    +#silent_mode = off      # Run server silently.
    +          # DO NOT USE without syslog or
    +          # logging_collector
    +          # (change requires restart)

    +
     # - When to Log -

    -#client_min_messages = notice              # values in order of decreasing detail:
    -                                   #   debug5
    -                                   #   debug4
    -                                   #   debug3
    -                                   #   debug2
    -                                   #   debug1
    -                                   #   log
    -                                   #   notice
    -                                   #   warning
    -                                   #   error
    +#client_min_messages = notice   # values in order of decreasing detail:
    +          #   debug5
    +          #   debug4
    +          #   debug3
    +          #   debug2
    +          #   debug1
    +          #   log
    +          #   notice
    +          #   warning
    +          #   error

    -#log_min_messages = warning                # values in order of decreasing detail:
    -                                   #   debug5
    -                                   #   debug4
    -                                   #   debug3
    -                                   #   debug2
    -                                   #   debug1
    -                                   #   info
    -                                   #   notice
    -                                   #   warning
    -                                   #   error
    -                                   #   log
    -                                   #   fatal
    -                                   #   panic
    +#log_min_messages = warning   # values in order of decreasing detail:
    +          #   debug5
    +          #   debug4
    +          #   debug3
    +          #   debug2
    +          #   debug1
    +          #   info
    +          #   notice
    +          #   warning
    +          #   error
    +          #   log
    +          #   fatal
    +          #   panic

    -#log_min_error_statement = error   # values in order of decreasing detail:
    -                                   #   debug5
    -                                   #   debug4
    -                                   #   debug3
    -                                   #   debug2
    -                                   #   debug1
    -                                   #   info
    -                                   #   notice
    -                                   #   warning
    -                                   #   error
    -                                   #   log
    -                                   #   fatal
    -                                   #   panic (effectively off)
    +#log_min_error_statement = error  # values in order of decreasing detail:
    +          #   debug5
    +          #   debug4
    +          #   debug3
    +          #   debug2
    +          #   debug1
    +          #   info
    +          #   notice
    +          #   warning
    +          #   error
    +          #   log
    +          #   fatal
    +          #   panic (effectively off)

    -#log_min_duration_statement = -1   # -1 is disabled, 0 logs all statements
    -                                   # and their durations, > 0 logs only
    -                                   # statements running at least this number
    -                                   # of milliseconds
    -
    -
     # - What to Log -

     #debug_print_parse = off
     #debug_print_rewritten = off
     #debug_print_plan = off
     #debug_pretty_print = on
    -#log_checkpoints = off
     #log_connections = off
     #log_disconnections = off
     #log_duration = off
    -#log_error_verbosity = default             # terse, default, or verbose messages
    +#log_error_verbosity = default    # terse, default, or verbose messages
     #log_hostname = off
    -#log_line_prefix = ''                      # special values:
    -                                   #   %a = application name
    -                                   #   %u = user name
    -                                   #   %d = database name
    -                                   #   %r = remote host and port
    -                                   #   %h = remote host
    -                                   #   %p = process ID
    -                                   #   %t = timestamp without milliseconds
    -                                   #   %m = timestamp with milliseconds
    -                                   #   %n = timestamp with milliseconds (as a Unix epoch)
    -                                   #   %i = command tag
    -                                   #   %e = SQL state
    -                                   #   %c = session ID
    -                                   #   %l = session line number
    -                                   #   %s = session start timestamp
    -                                   #   %v = virtual transaction ID
    -                                   #   %x = transaction ID (0 if none)
    -                                   #   %q = stop here in non-session
    -                                   #        processes
    -                                   #   %% = '%'
    -                                   # e.g. '<%u%%%d> '
    -#log_lock_waits = off                      # log lock waits >= deadlock_timeout
    -#log_statement = 'none'                    # none, ddl, mod, all
    -#log_replication_commands = off
    -#log_temp_files = -1                       # log temporary files equal or larger
    -                                   # than the specified size in kilobytes;
    -                                   # -1 disables, 0 logs all temp files
    -log_timezone = 'US/Pacific'
    +#log_lock_waits = off     # log lock waits >= deadlock_timeout
    +#log_statement = 'none'     # none, ddl, mod, all
    +#log_timezone = '(defaults to server environment setting)'


    -# - Process Title -
    -
    -#cluster_name = ''                 # added to process titles if nonempty
    -                                   # (change requires restart)
    -#update_process_title = on
    -
    -
     #------------------------------------------------------------------------------
     # RUNTIME STATISTICS
     #------------------------------------------------------------------------------
    @@ -473,9 +364,9 @@

     #track_activities = on
     #track_counts = on
    -#track_io_timing = off
    -#track_functions = none                    # none, pl, all
    -#track_activity_query_size = 1024  # (change requires restart)
    +#track_functions = none     # none, pl, all
    +track_activity_query_size = 1024 # (change requires restart)
    +#update_process_title = on
     #stats_temp_directory = 'pg_stat_tmp'


    @@ -491,93 +382,50 @@
     # AUTOVACUUM PARAMETERS
     #------------------------------------------------------------------------------

    -#autovacuum = on                   # Enable autovacuum subprocess?  'on'
    -                                   # requires track_counts to also be on.
    -#log_autovacuum_min_duration = -1  # -1 disables, 0 logs all actions and
    -                                   # their durations, > 0 logs only
    -                                   # actions running at least this number
    -                                   # of milliseconds.
    -#autovacuum_max_workers = 3                # max number of autovacuum subprocesses
    -                                   # (change requires restart)
    -#autovacuum_naptime = 1min         # time between autovacuum runs
    -#autovacuum_vacuum_threshold = 50  # min number of row updates before
    -                                   # vacuum
    -#autovacuum_analyze_threshold = 50 # min number of row updates before
    -                                   # analyze
    -#autovacuum_vacuum_scale_factor = 0.2      # fraction of table size before vacuum
    -#autovacuum_analyze_scale_factor = 0.1     # fraction of table size before analyze
    -#autovacuum_freeze_max_age = 200000000     # maximum XID age before forced vacuum
    -                                   # (change requires restart)
    -#autovacuum_multixact_freeze_max_age = 400000000   # maximum multixact age
    -                                   # before forced vacuum
    -                                   # (change requires restart)
    -#autovacuum_vacuum_cost_delay = 20ms       # default vacuum cost delay for
    -                                   # autovacuum, in milliseconds;
    -                                   # -1 means use vacuum_cost_delay
    -#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
    -                                   # autovacuum, -1 means use
    -                                   # vacuum_cost_limit
    -
    -
    +autovacuum_max_workers = 3 # max number of autovacuum subprocesses
    +          # (change requires restart)
    +autovacuum_freeze_max_age = 200000000  # maximum XID age before forced vacuum
    +          # (change requires restart)
     #------------------------------------------------------------------------------
     # CLIENT CONNECTION DEFAULTS
     #------------------------------------------------------------------------------

     # - Statement Behavior -

    -#search_path = '"$user", public'   # schema names
    -#default_tablespace = ''           # a tablespace name, '' uses the default
    -#temp_tablespaces = ''                     # a list of tablespace names, '' uses
    -                                   # only default tablespace
    +#search_path = '"$user",public'   # schema names
    +#default_tablespace = ''    # a tablespace name, '' uses the default
    +#temp_tablespaces = ''      # a list of tablespace names, '' uses
    +          # only default tablespace
     #check_function_bodies = on
     #default_transaction_isolation = 'read committed'
     #default_transaction_read_only = off
     #default_transaction_deferrable = off
     #session_replication_role = 'origin'
    -#statement_timeout = 0                     # in milliseconds, 0 is disabled
    -#lock_timeout = 0                  # in milliseconds, 0 is disabled
    -#idle_in_transaction_session_timeout = 0           # in milliseconds, 0 is disabled
     #vacuum_freeze_min_age = 50000000
     #vacuum_freeze_table_age = 150000000
    -#vacuum_multixact_freeze_min_age = 5000000
    -#vacuum_multixact_freeze_table_age = 150000000
    -#bytea_output = 'hex'                      # hex, escape
    +#bytea_output = 'hex'     # hex, escape
     #xmlbinary = 'base64'
     #xmloption = 'content'
    -#gin_fuzzy_search_limit = 0
    -#gin_pending_list_limit = 4MB

     # - Locale and Formatting -

    -datestyle = 'iso, mdy'
     #intervalstyle = 'postgres'
    -timezone = 'US/Pacific'
    +#timezone = '(defaults to server environment setting)'
     #timezone_abbreviations = 'Default'     # Select the set of available time zone
    -                                   # abbreviations.  Currently, there are
    -                                   #   Default
    -                                   #   Australia (historical usage)
    -                                   #   India
    -                                   # You can create your own file in
    -                                   # share/timezonesets/.
    -#extra_float_digits = 0                    # min -15, max 3
    -#client_encoding = sql_ascii               # actually, defaults to database
    -                                   # encoding
    +          # abbreviations.  Currently, there are
    +          #   Default
    +          #   Australia
    +          #   India
    +          # You can create your own file in
    +          # share/timezonesets/.
    +#extra_float_digits = 0     # min -15, max 3
    +#client_encoding = sql_ascii    # actually, defaults to database
    +          # encoding

    -# These settings are initialized by initdb, but they can be changed.
    -lc_messages = 'C.UTF-8'                    # locale for system error message
    -                                   # strings
    -lc_monetary = 'C.UTF-8'                    # locale for monetary formatting
    -lc_numeric = 'C.UTF-8'                     # locale for number formatting
    -lc_time = 'C.UTF-8'                                # locale for time formatting
    -
    -# default configuration for text search
    -default_text_search_config = 'pg_catalog.english'
    -
     # - Other Defaults -

     #dynamic_library_path = '$libdir'
     #local_preload_libraries = ''
    -#session_preload_libraries = ''


     #------------------------------------------------------------------------------
    @@ -585,12 +433,14 @@
     #------------------------------------------------------------------------------

     #deadlock_timeout = 1s
    -#max_locks_per_transaction = 64            # min 10
    -                                   # (change requires restart)
    -#max_pred_locks_per_transaction = 64       # min 10
    -                                   # (change requires restart)
    +max_locks_per_transaction = 64   # min 10
    +          # (change requires restart)
    +# Note:  Each lock table slot uses ~270 bytes of shared memory, and there are
    +# max_locks_per_transaction * (max_connections + max_prepared_transactions)
    +# lock table slots.
    +#max_pred_locks_per_transaction = 64  # min 10
    +          # (change requires restart)

    -
     #------------------------------------------------------------------------------
     # VERSION/PLATFORM COMPATIBILITY
     #------------------------------------------------------------------------------
    @@ -598,11 +448,10 @@
     # - Previous PostgreSQL Versions -

     #array_nulls = on
    -#backslash_quote = safe_encoding   # on, off, or safe_encoding
    +#backslash_quote = safe_encoding  # on, off, or safe_encoding
     #default_with_oids = off
     #escape_string_warning = on
     #lo_compat_privileges = off
    -#operator_precedence_warning = off
     #quote_all_identifiers = off
     #sql_inheritance = on
     #standard_conforming_strings = on
    @@ -617,26 +466,15 @@
     # ERROR HANDLING
     #------------------------------------------------------------------------------

    -#exit_on_error = off                       # terminate session on any error?
    -#restart_after_crash = on          # reinitialize after backend crash?
    +#exit_on_error = off        # terminate session on any error?
    +#restart_after_crash = on     # reinitialize after backend crash?


     #------------------------------------------------------------------------------
    -# CONFIG FILE INCLUDES
    -#------------------------------------------------------------------------------
    -
    -# These options allow settings to be loaded from files other than the
    -# default postgresql.conf.
    -
    -#include_dir = 'conf.d'                    # include files ending in '.conf' from
    -                                   # directory 'conf.d'
    -#include_if_exists = 'exists.conf' # include file only if it exists
    -#include = 'special.conf'          # include file
    -
    -
    -#------------------------------------------------------------------------------
     # CUSTOMIZED OPTIONS
     #------------------------------------------------------------------------------

    -# Add settings for extensions here
    +#custom_variable_classes = ''   # list of custom variable class names
    +
    +include 'runtime.conf'
    - change mode from '0600' to '0644'
  * template[/var/opt/gitlab/postgresql/data/runtime.conf] action create
    - create new file /var/opt/gitlab/postgresql/data/runtime.conf
    - update content in file /var/opt/gitlab/postgresql/data/runtime.conf from none to cd75cc
    --- /var/opt/gitlab/postgresql/data/runtime.conf    2017-06-22 10:53:24.903990582 -0700
    +++ /var/opt/gitlab/postgresql/data/.chef-runtime.conf20170622-25881-wbc3o  2017-06-22 10:53:24.903990582 -0700
    @@ -1 +1,114 @@
    +# This file is managed by gitlab-ctl. Manual changes will be
    +# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
    +# and run `sudo gitlab-ctl reconfigure`.
    +
    +# Changing variables in this file should only require a reload of PostgreSQL
    +# As the gitlab-psql user, run:
    +# /opt/gitlab/embedded/bin/pg_ctl reload -D /var/opt/gitlab/postgresql/data
    +work_mem = 8MB                             # min 64kB
    +maintenance_work_mem = 16MB # 16MB    # min 1MB
    +synchronous_commit = on # synchronization level; on, off, or local
    +synchronous_standby_names = ''
    +
    +# - Checkpoints -
    +min_wal_size = 80MB
    +max_wal_size = 1GB
    +
    +checkpoint_timeout = 5min          # range 30s-1h, default 5min
    +checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0, default 0.5
    +checkpoint_warning = 30s           # 0 disables, default 30s
    +
    +# - Archiving -
    +archive_command = ''   # command to use to archive a logfile segment
    +archive_timeout = 60    # force a logfile segment switch after this
    +        # number of seconds; 0 disables
    +
    +# - Replication
    +wal_keep_segments = 10
    +
    +max_standby_archive_delay = 30s # max delay before canceling queries
    +          # when reading WAL from archive;
    +          # -1 allows indefinite delay
    +max_standby_streaming_delay = 30s # max delay before canceling queries
    +          # when reading streaming WAL;
    +          # -1 allows indefinite delay
    +
    +hot_standby_feedback = off   # send info from standby to prevent
    +          # query conflicts
    +
    +# - Planner Cost Constants -
    +#seq_page_cost = 1.0      # measured on an arbitrary scale
    +random_page_cost = 4.0     # same scale as above
    +
    +effective_cache_size = 3943MB # Default 128MB
    +
    +log_min_duration_statement = -1  # -1 is disabled, 0 logs all statements
    +          # and their durations, > 0 logs only
    +          # statements running at least this number
    +          # of milliseconds
    +
    +log_checkpoints = off
    +
    +log_line_prefix = '' # default '', special values:
    +          #   %a = application name
    +          #   %u = user name
    +          #   %d = database name
    +          #   %r = remote host and port
    +          #   %h = remote host
    +          #   %p = process ID
    +          #   %t = timestamp without milliseconds
    +          #   %m = timestamp with milliseconds
    +          #   %i = command tag
    +          #   %e = SQL state
    +          #   %c = session ID
    +          #   %l = session line number
    +          #   %s = session start timestamp
    +          #   %v = virtual transaction ID
    +          #   %x = transaction ID (0 if none)
    +          #   %q = stop here in non-session
    +          #        processes
    +          #   %% = '%'
    +
    +log_temp_files = -1      # log temporary files equal or larger
    +          # than the specified size in kilobytes;
    +          # -1 disables, 0 logs all temp files
    +
    +# - Autovacuum parameters -
    +autovacuum = on # Enable autovacuum subprocess?  'on'
    +          # requires track_counts to also be on.
    +
    +log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and
    +          # their durations, > 0 logs only
    +          # actions running at least this number
    +          # of milliseconds.
    +
    +autovacuum_naptime = 1min # time between autovacuum runs
    +autovacuum_vacuum_threshold = 50 # min number of row updates before
    +          # vacuum
    +autovacuum_analyze_threshold = 50 # min number of row updates before
    +          # analyze
    +autovacuum_vacuum_scale_factor = 0.02 # fraction of table size before vacuum
    +autovacuum_analyze_scale_factor = 0.01 # fraction of table size before analyze
    +autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for
    +          # autovacuum, in milliseconds;
    +          # -1 means use vacuum_cost_delay
    +autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
    +          # autovacuum, -1 means use
    +          # vacuum_cost_limit
    +
    +# - Client connection timeouts
    +statement_timeout = 0
    +
    +# - Locale and Formatting -
    +datestyle = 'iso, mdy'
    +
    +# These settings are initialized by initdb, but they can be changed.
    +lc_messages = 'C'     # locale for system error message
    +          # strings
    +lc_monetary = 'C'     # locale for monetary formatting
    +lc_numeric = 'C'      # locale for number formatting
    +lc_time = 'C'       # locale for time formatting
    +
    +# default configuration for text search
    +default_text_search_config = 'pg_catalog.english'
    - change mode from '' to '0644'
    - change owner from '' to 'gitlab-psql'
  * template[/var/opt/gitlab/postgresql/data/pg_hba.conf] action create
    - update content in file /var/opt/gitlab/postgresql/data/pg_hba.conf from d7d331 to 40e348
    --- /var/opt/gitlab/postgresql/data/pg_hba.conf     2017-06-22 10:53:05.220077540 -0700
    +++ /var/opt/gitlab/postgresql/data/.chef-pg_hba.conf20170622-25881-1mv2wu4 2017-06-22 10:53:24.919990511 -0700
    @@ -1,94 +1,74 @@
    +# This file is managed by gitlab-ctl. Manual changes will be
    +# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
    +# and run `sudo gitlab-ctl reconfigure`.
    +
     # PostgreSQL Client Authentication Configuration File
     # ===================================================
     #
    -# Refer to the "Client Authentication" section in the PostgreSQL
    -# documentation for a complete description of this file.  A short
    -# synopsis follows.
    +# Refer to the "Client Authentication" section in the
    +# PostgreSQL documentation for a complete description
    +# of this file.  A short synopsis follows.
     #
     # This file controls: which hosts are allowed to connect, how clients
     # are authenticated, which PostgreSQL user names they can use, which
     # databases they can access.  Records take one of these forms:
     #
    -# local      DATABASE  USER  METHOD  [OPTIONS]
    -# host       DATABASE  USER  ADDRESS  METHOD  [OPTIONS]
    -# hostssl    DATABASE  USER  ADDRESS  METHOD  [OPTIONS]
    -# hostnossl  DATABASE  USER  ADDRESS  METHOD  [OPTIONS]
    +# local      DATABASE  USER  METHOD  [OPTION]
    +# host       DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
    +# hostssl    DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
    +# hostnossl  DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
     #
     # (The uppercase items must be replaced by actual values.)
     #
    -# The first field is the connection type: "local" is a Unix-domain
    -# socket, "host" is either a plain or SSL-encrypted TCP/IP socket,
    -# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a
    -# plain TCP/IP socket.
    +# The first field is the connection type: "local" is a Unix-domain socket,
    +# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
    +# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
     #
    -# DATABASE can be "all", "sameuser", "samerole", "replication", a
    -# database name, or a comma-separated list thereof. The "all"
    -# keyword does not match "replication". Access to replication
    -# must be enabled in a separate record (see example below).
    +# DATABASE can be "all", "sameuser", "samerole", a database name, or
    +# a comma-separated list thereof.
     #
    -# USER can be "all", a user name, a group name prefixed with "+", or a
    -# comma-separated list thereof.  In both the DATABASE and USER fields
    -# you can also write a file name prefixed with "@" to include names
    -# from a separate file.
    +# USER can be "all", a user name, a group name prefixed with "+", or
    +# a comma-separated list thereof.  In both the DATABASE and USER fields
    +# you can also write a file name prefixed with "@" to include names from
    +# a separate file.
     #
    -# ADDRESS specifies the set of hosts the record matches.  It can be a
    -# host name, or it is made up of an IP address and a CIDR mask that is
    -# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that
    -# specifies the number of significant bits in the mask.  A host name
    -# that starts with a dot (.) matches a suffix of the actual host name.
    -# Alternatively, you can write an IP address and netmask in separate
    -# columns to specify the set of hosts.  Instead of a CIDR-address, you
    -# can write "samehost" to match any of the server's own IP addresses,
    -# or "samenet" to match any address in any subnet that the server is
    -# directly connected to.
    +# CIDR-ADDRESS specifies the set of hosts the record matches.
    +# It is made up of an IP address and a CIDR mask that is an integer
    +# (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies
    +# the number of significant bits in the mask.  Alternatively, you can write
    +# an IP address and netmask in separate columns to specify the set of hosts.
     #
    -# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi",
    -# "ident", "peer", "pam", "ldap", "radius" or "cert".  Note that
    -# "password" sends passwords in clear text; "md5" is preferred since
    -# it sends encrypted passwords.
    +# METHOD can be "trust", "reject", "md5", "crypt", "password", "gss", "sspi",
    +# "krb5", "ident", "pam" or "ldap".  Note that "password" sends passwords
    +# in clear text; "md5" is preferred since it sends encrypted passwords.
     #
    -# OPTIONS are a set of options for the authentication in the format
    -# NAME=VALUE.  The available options depend on the different
    -# authentication methods -- refer to the "Client Authentication"
    -# section in the documentation for a list of which options are
    -# available for which authentication methods.
    +# OPTION is the ident map or the name of the PAM service, depending on METHOD.
     #
    -# Database and user names containing spaces, commas, quotes and other
    -# special characters must be quoted.  Quoting one of the keywords
    -# "all", "sameuser", "samerole" or "replication" makes the name lose
    -# its special character, and just match a database or username with
    -# that name.
    +# Database and user names containing spaces, commas, quotes and other special
    +# characters must be quoted. Quoting one of the keywords "all", "sameuser" or
    +# "samerole" makes the name lose its special character, and just match a
    +# database or username with that name.
     #
     # This file is read on server startup and when the postmaster receives
     # a SIGHUP signal.  If you edit the file on a running system, you have
    -# to SIGHUP the postmaster for the changes to take effect.  You can
    -# use "pg_ctl reload" to do that.
    +# to SIGHUP the postmaster for the changes to take effect.  You can use
    +# "pg_ctl reload" to do that.

     # Put your actual configuration here
     # ----------------------------------
     #
     # If you want to allow non-local connections, you need to add more
    -# "host" records.  In that case you will also need to make PostgreSQL
    -# listen on a non-local interface via the listen_addresses
    -# configuration parameter, or via the -i or -h command line switches.
    +# "host" records. In that case you will also need to make PostgreSQL listen
    +# on a non-local interface via the listen_addresses configuration parameter,
    +# or via the -i or -h command line switches.
    +#

    -# CAUTION: Configuring the system for local "trust" authentication
    -# allows any local user to connect as any PostgreSQL user, including
    -# the database superuser.  If you do not trust all your local users,
    -# use another authentication method.

    +# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

    -# TYPE  DATABASE        USER            ADDRESS                 METHOD
    -
     # "local" is for Unix domain socket connections only
    -local   all             all                                     trust
    -# IPv4 local connections:
    -host    all             all             127.0.0.1/32            trust
    -# IPv6 local connections:
    -host    all             all             ::1/128                 trust
    -# Allow replication connections from localhost, by a user with the
    -# replication privilege.
    -#local   replication     gitlab-psql                                trust
    -#host    replication     gitlab-psql        127.0.0.1/32            trust
    -#host    replication     gitlab-psql        ::1/128                 trust
    +local   all         all                               peer map=gitlab
    +
    +
    +
    - change mode from '0600' to '0644'
  * template[/var/opt/gitlab/postgresql/data/pg_ident.conf] action create
    - update content in file /var/opt/gitlab/postgresql/data/pg_ident.conf from 297f46 to 5399a1
    --- /var/opt/gitlab/postgresql/data/pg_ident.conf   2017-06-22 10:53:05.224077523 -0700
    +++ /var/opt/gitlab/postgresql/data/.chef-pg_ident.conf20170622-25881-ozx6zs        2017-06-22 10:53:24.943990404 -0700
    @@ -40,4 +40,8 @@
     # ----------------------------------

     # MAPNAME       SYSTEM-USERNAME         PG-USERNAME
    +gitlab  git  gitlab
    +gitlab  mattermost  gitlab_mattermost
    +# Default to a 1-1 mapping between system usernames and Postgres usernames
    +gitlab  /^(.*)$  \1
    - change mode from '0600' to '0644'
  * directory[/opt/gitlab/sv/postgresql] action create (up to date)
  * directory[/opt/gitlab/sv/postgresql/log] action create (up to date)
  * directory[/opt/gitlab/sv/postgresql/log/main] action create (up to date)
  * template[/opt/gitlab/sv/postgresql/run] action create (up to date)
  * template[/opt/gitlab/sv/postgresql/log/run] action create (up to date)
  * template[/var/log/gitlab/postgresql/config] action create (up to date)
  * ruby_block[reload postgresql svlogd configuration] action nothing (skipped due to action :nothing)
  * file[/opt/gitlab/sv/postgresql/down] action delete (up to date)
  * directory[/opt/gitlab/sv/postgresql/control] action create (up to date)
  * template[/opt/gitlab/sv/postgresql/control/t] action create (up to date)
  * link[/opt/gitlab/init/postgresql] action create (up to date)
  * link[/opt/gitlab/service/postgresql] action create (up to date)
  * ruby_block[supervise_postgresql_sleep] action run (skipped due to not_if)
  * directory[/opt/gitlab/sv/postgresql/supervise] action create (up to date)
  * directory[/opt/gitlab/sv/postgresql/log/supervise] action create (up to date)
  * file[/opt/gitlab/sv/postgresql/supervise/ok] action touch
    - create new file /opt/gitlab/sv/postgresql/supervise/ok
    - change owner from '' to 'gitlab-psql'
    - change group from '' to 'gitlab-psql'
    - update utime on file /opt/gitlab/sv/postgresql/supervise/ok
  * file[/opt/gitlab/sv/postgresql/log/supervise/ok] action touch
    - create new file /opt/gitlab/sv/postgresql/log/supervise/ok
    - change owner from '' to 'gitlab-psql'
    - change group from '' to 'gitlab-psql'
    - update utime on file /opt/gitlab/sv/postgresql/log/supervise/ok
  * file[/opt/gitlab/sv/postgresql/supervise/control] action touch
    - create new file /opt/gitlab/sv/postgresql/supervise/control
    - change owner from '' to 'gitlab-psql'
    - change group from '' to 'gitlab-psql'
    - update utime on file /opt/gitlab/sv/postgresql/supervise/control
  * file[/opt/gitlab/sv/postgresql/log/supervise/control] action touch
    - create new file /opt/gitlab/sv/postgresql/log/supervise/control
    - change owner from '' to 'gitlab-psql'
    - change group from '' to 'gitlab-psql'
    - update utime on file /opt/gitlab/sv/postgresql/log/supervise/control
  * service[postgresql] action nothing (skipped due to action :nothing)
Recipe: gitlab::postgresql-bin
  * ruby_block[Link postgresql bin files to the correct version] action run (skipped due to only_if)
Recipe: gitlab::postgresql
  * template[/opt/gitlab/etc/gitlab-psql-rc] action create (up to date)
  * postgresql_user[gitlab] action create
    * execute[create gitlab postgresql user] action run (skipped due to not_if)
     (up to date)
  * execute[create gitlabhq_production database] action run (skipped due to not_if)
  * postgresql_user[gitlab_replicator] action create
    * execute[create gitlab_replicator postgresql user] action run (skipped due to not_if)
     (up to date)
  * execute[enable pg_trgm extension] action nothing (skipped due to action :nothing)
  * execute[reload postgresql] action nothing (skipped due to action :nothing)
  * execute[start postgresql] action nothing (skipped due to action :nothing)
Recipe: gitlab::database_migrations
  * bash[migrate gitlab-rails database] action run
    - Would execute "bash"  "/tmp/chef-script20170622-25881-yi9s91"
Recipe: gitlab::postgresql
  * execute[enable pg_trgm extension] action run (skipped due to not_if)
Recipe: gitlab::database_migrations
  * bash[migrate gitlab-rails database] action run
    [execute] rake aborted!
              PG::ConnectionBad: could not connect to server: No such file or directory
                Is the server running locally and accepting
                connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
              /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:49:in `block (3 levels) in <main>'
              /opt/gitlab/embedded/bin/bundle:22:in `load'
              /opt/gitlab/embedded/bin/bundle:22:in `<main>'
              Tasks: TOP => gitlab:db:configure
              (See full trace by running task with --trace)

    ================================================================================
    Error executing action `run` on resource 'bash[migrate gitlab-rails database]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of "bash"  "/tmp/chef-script20170622-25881-6bdle6" ----
    STDOUT: rake aborted!
    PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:49:in `block (3 levels) in <main>'
    /opt/gitlab/embedded/bin/bundle:22:in `load'
    /opt/gitlab/embedded/bin/bundle:22:in `<main>'
    Tasks: TOP => gitlab:db:configure
    (See full trace by running task with --trace)
    STDERR:
    ---- End output of "bash"  "/tmp/chef-script20170622-25881-6bdle6" ----
    Ran "bash"  "/tmp/chef-script20170622-25881-6bdle6" returned 1

    Resource Declaration:
    ---------------------
    # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb

     51: bash "migrate gitlab-rails database" do
     52:   code <<-EOH
     53:     set -e
     54:     log_file="#{node['gitlab']['gitlab-rails']['log_directory']}/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log"
     55:     umask 077
     56:     /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}
     57:     STATUS=${PIPESTATUS[0]}
     58:     echo $STATUS > #{db_migrate_status_file}
     59:     exit $STATUS
     60:   EOH
     61:   environment env_variables unless env_variables.empty?
     62:   notifies :run, 'execute[enable pg_trgm extension]', :before if omnibus_helper.service_enabled?('postgresql')
     63:   notifies :run, "execute[clear the gitlab-rails cache]", :immediately
     64:   dependent_services.each do |svc|
     65:     notifies :restart, svc, :immediately
     66:   end
     67:   not_if "(test -f #{db_migrate_status_file}) && (cat #{db_migrate_status_file} | grep -Fx 0)"
     68:   only_if { node['gitlab']['gitlab-rails']['auto_migrate'] }
     69: end

    Compiled Resource:
    ------------------
    # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/database_migrations.rb:51:in `from_file'

    bash("migrate gitlab-rails database") do
      action [:run]
      updated true
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      command "migrate gitlab-rails database"
      backup 5
      returns 0
      code "    set -e\n    log_file=\"/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log\"\n    umask 077\n    /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}\n    STATUS=${PIPESTATUS[0]}\n    echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-acb7f25\n    exit $STATUS\n"
      interpreter "bash"
      declared_type :bash
      cookbook_name "gitlab"
      recipe_name "database_migrations"
      not_if "(test -f /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-acb7f25) && (cat /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-873248b1f0d3a7a5535771a3a1635803-acb7f25 | grep -Fx 0)"
      only_if { #code block }
    end

    Platform:
    ---------
    x86_64-linux


Running handlers:
Running handlers complete
Chef Client failed. 13 resources updated in 14 seconds
Running reconfigure: NOT OK
== Fatal error ==
Something went wrong during final reconfiguration, please check the output
== Reverting ==
ok: down: postgresql: 30s, normally up
ok: run: postgresql: (pid 26451) 1s
== Reverted ==
== Reverted to 9.2.18. Please check output for what went wrong ==
Toggling deploy page:rm -f /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: run: logrotate: (pid 26463) 0s
ok: run: mailroom: (pid 26469) 1s
ok: run: sidekiq: (pid 26473) 0s
Toggling services: OK