Commit 5079e8f5 authored by Kamil Trzciński's avatar Kamil Trzciński

Remove `FF_LEGACY_PERSISTED_NAMES` feature flag

The new method of fetching feature flags
seems to behave correctly.

This is safe to remove the feature flag.
parent 31307c8b
......@@ -34,18 +34,6 @@ class Feature
def persisted_names
return [] unless Gitlab::Database.exists?
if Gitlab::Utils.to_boolean(ENV['FF_LEGACY_PERSISTED_NAMES'])
# To be removed:
# This uses a legacy persisted names that are know to work (always)
Gitlab::SafeRequestStore[:flipper_persisted_names] ||=
begin
# We saw on GitLab.com, this database request was called 2300
# times/s. Let's cache it for a minute to avoid that load.
Gitlab::ProcessMemoryCache.cache_backend.fetch('flipper:persisted_names', expires_in: 1.minute) do
FlipperFeature.feature_names
end.to_set
end
else
# This loads names of all stored feature flags
# and returns a stable Set in the following order:
# - Memoized: using Gitlab::SafeRequestStore or @flipper
......@@ -54,7 +42,6 @@ class Feature
# - DB: using a single SQL query
flipper.adapter.features
end
end
def persisted_name?(feature_name)
# Flipper creates on-memory features when asked for a not-yet-created one.
......
......@@ -21,11 +21,6 @@ RSpec.describe Feature, stub_feature_flags: false do
end
describe '.persisted_names' do
context 'when FF_LEGACY_PERSISTED_NAMES=false' do
before do
stub_env('FF_LEGACY_PERSISTED_NAMES', 'false')
end
it 'returns the names of the persisted features' do
Feature.enable('foo')
......@@ -50,38 +45,6 @@ RSpec.describe Feature, stub_feature_flags: false do
expect(described_class.persisted_names).to contain_exactly('foo')
end
end
end
context 'when FF_LEGACY_PERSISTED_NAMES=true' do
before do
stub_env('FF_LEGACY_PERSISTED_NAMES', 'true')
end
it 'returns the names of the persisted features' do
Feature.enable('foo')
expect(described_class.persisted_names).to contain_exactly('foo')
end
it 'returns an empty Array when no features are presisted' do
expect(described_class.persisted_names).to be_empty
end
it 'caches the feature names when request store is active',
:request_store, :use_clean_rails_memory_store_caching do
Feature.enable('foo')
expect(Gitlab::ProcessMemoryCache.cache_backend)
.to receive(:fetch)
.once
.with('flipper:persisted_names', expires_in: 1.minute)
.and_call_original
2.times do
expect(described_class.persisted_names).to contain_exactly('foo')
end
end
end
it 'fetches all flags once in a single query', :request_store do
Feature.enable('foo1')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment