Allow percentage rollout of load balancer of decomposed database
What does this MR do and why?
This introduces a GITLAB_USE_MODEL_LOAD_BALANCING
and use_model_load_balancing
to enable percentage rollout
of used connection when accessing data.
The usage pattern is to redirect 1% of new connections using CI DB to use a Load Balancer replicas (and presumably later primary connection).
This is achieved by injecting a FF evaluation logic as part of LB setup to re-define how connection is fetched.
This is not the nicest implementation, but this appears to be the only sane inject way of this functionality.
Related to:
Behavior
It introduces a ENV (which takes precedence) and FF (which is easy to model 1% rollout). The FF is sticky to the current request. If request store is not active this fallbacks to being disabled unless explicitly defined with ENV variable.
GITLAB USE_MODEL LOAD_BALANCING | GITLAB LOAD_BALANCING REUSE_PRIMARY ci | Request Store active? | use_model load_balancing FF | ActiveRecord Base primary | ActiveRecord Base replica | Ci ApplicationRecord connection | Ci ApplicationRecord replica |
---|---|---|---|---|---|---|---|
TRUE | undefined | ignored | ignored | main primary | main replica | ci primary | ci replica |
TRUE | main | ignored | ignored | main primary | main replica | main primary | ci replica |
FALSE | undefined | ignored | ignored | main primary | main replica | main primary | main replica |
FALSE | main | ignored | ignored | main primary | main replica | main primary | main replica |
undefined | undefined | FALSE | FALSE | main primary | main replica | main primary | main replica |
undefined | undefined | FALSE | TRUE | main primary | main replica | main primary | main replica |
undefined | undefined | TRUE | FALSE | main primary | main replica | main primary | main replica |
undefined | undefined | TRUE | TRUE | main primary | main replica | ci primary | ci replica |
undefined | main | FALSE | FALSE | main primary | main replica | main primary | main replica |
undefined | main | FALSE | TRUE | main primary | main replica | main primary | main replica |
undefined | main | TRUE | FALSE | main primary | main replica | main primary | main replica |
undefined | main | TRUE | TRUE | main primary | main replica | main primary | ci replica |
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.