Commit cf6c99bc authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'yorick/remove-old-redis-key-sticking' into 'master'

Remove support for sticking to old and new keys

See merge request gitlab-org/gitlab!74784
parents 05004557 9622020c
......@@ -123,21 +123,18 @@ module Gitlab
def unstick(namespace, id)
Gitlab::Redis::SharedState.with do |redis|
redis.del(redis_key_for(namespace, id))
redis.del(old_redis_key_for(namespace, id))
end
end
def set_write_location_for(namespace, id, location)
Gitlab::Redis::SharedState.with do |redis|
redis.set(redis_key_for(namespace, id), location, ex: EXPIRATION)
redis.set(old_redis_key_for(namespace, id), location, ex: EXPIRATION)
end
end
def last_write_location_for(namespace, id)
Gitlab::Redis::SharedState.with do |redis|
redis.get(redis_key_for(namespace, id)) ||
redis.get(old_redis_key_for(namespace, id))
redis.get(redis_key_for(namespace, id))
end
end
......@@ -146,10 +143,6 @@ module Gitlab
"database-load-balancing/write-location/#{name}/#{namespace}/#{id}"
end
def old_redis_key_for(namespace, id)
"database-load-balancing/write-location/#{namespace}/#{id}"
end
end
end
end
......
......@@ -256,15 +256,6 @@ RSpec.describe Gitlab::Database::LoadBalancing::Sticking, :redis do
expect(sticking.last_write_location_for(:user, 4)).to be_nil
end
it 'removes the old key' do
Gitlab::Redis::SharedState.with do |redis|
redis.set(sticking.send(:old_redis_key_for, :user, 4), 'foo', ex: 30)
end
sticking.unstick(:user, 4)
expect(sticking.last_write_location_for(:user, 4)).to be_nil
end
end
describe '#last_write_location_for' do
......@@ -273,14 +264,6 @@ RSpec.describe Gitlab::Database::LoadBalancing::Sticking, :redis do
expect(sticking.last_write_location_for(:user, 4)).to eq('foo')
end
it 'falls back to reading the old key' do
Gitlab::Redis::SharedState.with do |redis|
redis.set(sticking.send(:old_redis_key_for, :user, 4), 'foo', ex: 30)
end
expect(sticking.last_write_location_for(:user, 4)).to eq('foo')
end
end
describe '#redis_key_for' 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