Skip to content

Use ind_jsonb type class directly for ApplicationSetting

Marius Bobin requested to merge 383153-fix-application-settings-cache into master

What does this MR do and why?

This is a work around for fixing the memory cache for ApplicationSetting during code reloads. I'm not sure who holds the reference to the unloaded type, but this seems to work for now. 😅

How to set up and validate locally

On master open a rails console, wait for it to load and execute a reload! command. This is the error that will show and crash the process:

TypeError: Gitlab::Database::Type::IndifferentJsonb can't be referred to
from /Users/marius/.gem/ruby/2.7.5/gems/activesupport-6.1.6.1/lib/active_support/cache.rb:841:in `dump'
[2] pry(main)>

this points to

      # Duplicates the value in a class. This is used by cache implementations that don't natively
      # serialize entries to protect against accidental cache modifications.
      def dup_value!
        if @value && !compressed? && !(@value.is_a?(Numeric) || @value == true || @value == false)
          if @value.is_a?(String)
            @value = @value.dup
          else
            @value = Marshal.load(Marshal.dump(@value))
          end
        end
      end

Here we're trying to dump an ApplicationSetting instance with an instance of the Type class that doesn't exist anymore.

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

Edited by Marius Bobin

Merge request reports