Skip to content

Default to two database connections i.e. main and ci

Abdul Wadood requested to merge 7451-default-to-two-connections into master

What does this MR do?

Default to two database connections i.e. main and ci

As part of bringing database decomposition support to self-managed we require self-managed to have two connections by default. Both these connections will point to the same database but can be configured to point to two different databases by overriding the defaults in /etc/gitlab/gitlab.rb.

The users can switch back to a single connection if they encounter any issues by overriding the default by adding the following in /etc/gitlab/gitlab.rb:

`gitlab_rails['databases']['ci']['enable'] = false`

Related issues

Closes #7451 (closed)

How to validate the changes

  1. Checkout the changes and run gitlab-ctl reconfigure.
  2. gitlab-rails/config/database.yml should contain a ci section which is a copy of the main section except database_tasks should be false.
  3. Disable two connections by overriding the default by adding gitlab_rails['databases']['ci']['enable'] = false in /etc/gitlab/gitlab.rb.
  4. Run gitlab-ctl reconfigure again and the ci section should not be present in database.yml.
Sample database.yml
# 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`.

production:
  main:
    adapter: postgresql
    encoding: unicode
    collation:
    database: gitlabhq_production
    username: "gitlab"
    password:
    host: "/var/opt/gitlab/postgresql"
    port: 5432
    socket:
    sslmode:
    sslcompression: 0
    sslrootcert:
    sslca:
    load_balancing: {"hosts":[]}
    prepared_statements: false
    database_tasks: true
    statement_limit: 1000
    connect_timeout:
    keepalives:
    keepalives_idle:
    keepalives_interval:
    keepalives_count:
    tcp_user_timeout:
    application_name:
    variables:
      statement_timeout:
  ci:
    adapter: postgresql
    encoding: unicode
    collation:
    database: gitlabhq_production
    username: "gitlab"
    password:
    host: "/var/opt/gitlab/postgresql"
    port: 5432
    socket:
    sslmode:
    sslcompression: 0
    sslrootcert:
    sslca:
    load_balancing: {"hosts":[]}
    prepared_statements: false
    database_tasks: false
    statement_limit: 1000
    connect_timeout:
    keepalives:
    keepalives_idle:
    keepalives_interval:
    keepalives_count:
    tcp_user_timeout:
    application_name:
    variables:
      statement_timeout:

Checklist

See Definition of done.

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

Required

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • [-] If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • [-] If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • [-] If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes. See "How to validate the changes" above
  • Documentation created/updated.
  • Tests added.
  • [-] Integration tests added to GitLab QA.
  • Equivalent MR/issue for the GitLab Chart opened. => !6850 (merged)
  • [-] Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Thong Kuah

Merge request reports