Commit a6b6779c authored by Sean McGivern's avatar Sean McGivern

Remove feature flag for using UNLINK in Redis

UNLINK was added in Redis 4. We put this usage of it behind a feature
flag in case there was an issue, and also added a fallback for instances
using Redis 3.

We no longer support Redis 3 and we haven't needed to disable the
feature flag, so we can just simplify this to always use UNLINK.
parent dc6fa046
...@@ -22,7 +22,7 @@ module Gitlab ...@@ -22,7 +22,7 @@ module Gitlab
keys = keys.map { |key| cache_key(key) } keys = keys.map { |key| cache_key(key) }
Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
unlink_or_delete(redis, keys) redis.unlink(*keys)
end end
end end
end end
...@@ -60,17 +60,5 @@ module Gitlab ...@@ -60,17 +60,5 @@ module Gitlab
def with(&blk) def with(&blk)
Gitlab::Redis::Cache.with(&blk) # rubocop:disable CodeReuse/ActiveRecord Gitlab::Redis::Cache.with(&blk) # rubocop:disable CodeReuse/ActiveRecord
end end
def unlink_or_delete(redis, keys)
if Feature.enabled?(:repository_set_cache_unlink, default_enabled: true)
redis.unlink(*keys)
else
redis.del(*keys)
end
rescue ::Redis::CommandError => e
Gitlab::ErrorTracking.log_exception(e)
redis.del(*keys)
end
end end
end end
...@@ -93,23 +93,6 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do ...@@ -93,23 +93,6 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
it { is_expected.to eq(0) } it { is_expected.to eq(0) }
end end
context "unlink isn't supported" do
before do
allow_any_instance_of(Redis).to receive(:unlink) { raise ::Redis::CommandError }
end
it 'still deletes the given key' do
expect(cache.expire(:foo)).to eq(1)
expect(cache.read(:foo)).to be_empty
end
it 'logs the failure' do
expect(Gitlab::ErrorTracking).to receive(:log_exception)
cache.expire(:foo)
end
end
end end
describe '#exist?' do describe '#exist?' do
......
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