Support loading session from ActionDispatch::Session::CacheStore
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 (merged).
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:
- Provide a rollback option after we've switched to
CacheStorein !176108 (merged). In case something goes wrong, the oldRedisStorecould still read session data from the newCacheStore. - Safer to roll out the changes in
RedisStorein 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
- On master branch, sign in as a user
- Check out to this branch, restart rails
gdk restart rails-web - Refresh browser, you should still be signed in.
- Try logging out and logging in again.
