Skip to content

Introduce feature flag to allow gradually rolling out separate read-write (primary) connection for ci database (Phase 4)

What does this MR do and why?

Per our rollout plan &6160 (closed) of separating the CI database from the main database the "phase 4" will involve gradually changing a percentage of "read-write" (primary) traffic to go through a new connection that still points to the same database.

Previously we added the GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci environment variable to allow us to share the same primary connection when there is a separate ci entry in config/database.yml. But we need to a way to override this environment variable so this MR introduces a new feature flag force_no_sharing_primary_model which overrides the "reuse" connection and forces it to not reuse the connection.

Screenshots or screen recordings

How to set up and validate locally

Set the following environment variables for rails:

GITLAB_USE_MODEL_LOAD_BALANCING=1
GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci=main
GITLAB_MULTIPLE_DATABASE_METRICS=1

Configure a separate ci connection in config/database.yml which points to the same database as main and also configure replicas for both. Both primaries and replicas can point to the same host or you can configure a replica with some latency for the replicas but both primaries for ci and main must be the same (only) writable host.

Enable the force_no_sharing_primary_model feature flag.

Test some CI features to be sure things are working like the following test plan !76188 (comment 842582338)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #347203 (closed)

Edited by Adam Hegyi

Merge request reports