Set ActiveSupport cache_format_version to 7.1 when upgrading to Rails 7.2

Context

Stemmed from discussion here !178869 (comment 2315591441).

We currently pass a custom coder Gitlab::Sessions::CacheStoreCoder to the session store here.

This custom coder is needed to support backwards compatibility of reading old session format from Gitlab::Sessions::RedisStore. The coder ensures any old sessions for self-managed instances can be read properly. The full context on this can be found here.

The existing serializer of :marshal_6_1 is removed in Rails 7.2. However, Rails 7.2 defaults the serializer to use 7.0 instead, in which the serialized data has different signature than 6.1 https://github.com/rails/rails/blob/v7.2.2.1/activesupport/lib/active_support/cache/serializer_with_fallback.rb#L66-L97.

Looking at the next serializer version of 7.1, the dump and load methods do match with the 6.1. Thus, as @reprazent suggested, we could skip 7.0 and go straight to 7.1 instead, and we could still maintain backwards compatibility with the old session format from the Gitlab::Sessions::RedisStore.

Proposal

diff --git a/lib/gitlab/sessions/cache_store_coder.rb b/lib/gitlab/sessions/cache_store_coder.rb
index 7261875fdf98..4200c3347861 100644
--- a/lib/gitlab/sessions/cache_store_coder.rb
+++ b/lib/gitlab/sessions/cache_store_coder.rb
@@ -4,12 +4,7 @@ module Gitlab
   module Sessions
     module CacheStoreCoder
       extend self
-
-      if ::Gitlab.next_rails?
-        include ActiveSupport::Cache::SerializerWithFallback[:marshal_6_1]
-      else
-        include ActiveSupport::Cache::Coders::Rails61Coder
-      end
+      include ActiveSupport::Cache::SerializerWithFallback[:marshal_7_1]
 
       def load(payload)
         unmarshalled = super
  • Perform manual tests to check whether sessions written by 6.1 can be read by the 7.1, ie login locally with master branch, checkout to the feature branch, restart rails, and refresh browser to ensure the session is still logged in.