Skip to content

[Follow up] Add use_pirmary_store_as_default feature flag for MultiStore [RUN ALL RSPEC]

Nikola Milojevic requested to merge 1334-add-use-primary-store-feature-flag into master

The Follow-up item from gitlab-com/gl-infra/scalability#1334 (closed)

What does this MR do and why?

It adds additional feature flag, so we will have more control with the multistore:

  1. GITLAB_USE_REDIS_SESSIONS_STORE enabled:
    1. use_primary_and_secondary_stores_for_sessions disabled (default):
      • use_primary_store_as_default_for_sessions disabled (default): we use SessionStore's MultiStore, but this falls back to just to the secondary_store (SharedState) as a default store due to the FF being disabled. This is the default state.
      • use_primary_store_as_default_for_sessions enabled: we use SessionStore's MultiStore, but it uses only the primary_store (Sessions) as a default store due to the FF being enabled. This can be used when the transition is over, and we see no fallbacks to read from the SharedState anymore.
    2. use_primary_and_secondary_stores_for_sessions enabled: we are writing to both primary and secondary (Sessions and SharedState) stores and we read from primary with fallback to the secondary store.
      • use_primary_store_as_default_for_sessions disabled: All from above (multi-read/write), but method missing will execute a missing command on the secondary_store (SharedState) as it is a default store.
      • use_primary_store_as_default_for_sessions enabled: All from above (multi-read/write), but method missing will execute a missing command on the primary_store (Sessions) store as it is a default store.
  2. GITLAB_USE_REDIS_SESSIONS_STORE disabled:
    1. We always use SharedState, which has no MultiStore, so the FF has no effect.

Each Redis store can have its set of feature flags when using multi store. This way, we could use MultiStore instances for multiple Redis stores, and control each of them separately. Example:

class instance_name use_primary_store_as_default ff use_primary_and_secondary_stores ff default_enabled
Gitlab::Redis::Sessions Sessions use_primary_and_secondary_stores_for_sessions use_primary_store_as_default_for_sessions
Gitlab::Redis::NewStore New Store use_primary_and_secondary_stores_for_new_store use_primary_store_as_default_for_new_store

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

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 #1334 (closed)

Edited by Nikola Milojevic

Merge request reports