Skip to content

Support loading session from ActionDispatch::Session::CacheStore

Gregorius Marco requested to merge mg-serializer-for-redis-store-session into master

What does this MR do and why?

We're preparing migration for our Gitlab::Redis::Sessions to a Redis Cluster in response to a saturation forecast.

To migrate sessions, we'll need to change our session store (Rails.application.config.session_store) from ActionDispatch::Session::RedisStore to ActionDispatch::Session::CacheStore. That is addressed in !176108.

The main difference between both stores lie in the format of the session data. RedisStore stores a marshal of the session hash, whereas CacheStore first wraps the session hash in ActiveSupport::Cache::Entry then being marshalled.

This MR supports RedisStore to read session data written by CacheStore by passing a custom serializer to the RedisStore initialization. This MR doesn't change any behavior of the current session management.

The purposes of this MR are:

  1. Provide a rollback option after we've switched to CacheStore in !176108. In case something goes wrong, the old RedisStore could still read session data from the new CacheStore.
  2. Safer to roll out the changes in RedisStore in an isolated MR.

This MR is the first MR from the series of MR in gitlab-com/gl-infra/data-access/durability/team#35 (comment 2278902354).

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

With currently logged in user

  1. On master branch, sign in as a user
  2. Check out to this branch, restart rails gdk restart rails-web
  3. Refresh browser, you should still be signed in.
  4. Try logging out and logging in again.

From fresh login

  1. On this branch, restart gdk restart rails-web

  2. Flush sessions in Redis gdk redis-cli -n 5 flushdb

  3. Clear cookie in browser image

  4. Try to login, browse around, everything should work normally.

Edited by Gregorius Marco

Merge request reports

Loading