summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorImre Farkas <ifarkas@gitlab.com>2019-07-12 14:25:12 +0200
committerImre Farkas <ifarkas@gitlab.com>2019-07-22 17:15:57 +0200
commit313f145b5594ebba7ce4675905061144adb3b44a (patch)
tree33683a02092d00fd587832dd40f99c5452dd2454 /app
parentc5fac1034f43d81a17242d8ade2d7eb8741a72e2 (diff)
downloadgitlab-ce-313f145b5594ebba7ce4675905061144adb3b44a.tar.gz
Rake task to cleanup expired ActiveSession lookup keysif-64257-active_session_lookup_key_cleanup
In some cases ActiveSession.cleanup was not called after authentication, so for some user ActiveSession lookup keys grew without ever cleaning up. This Rake task manually iterates over the lookup keys and removes ones without existing ActiveSession.
Diffstat (limited to 'app')
-rw-r--r--app/models/active_session.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/active_session.rb b/app/models/active_session.rb
index 345767179eb..fdd210f0fba 100644
--- a/app/models/active_session.rb
+++ b/app/models/active_session.rb
@@ -93,12 +93,12 @@ class ActiveSession
end
def self.list_sessions(user)
- sessions_from_ids(session_ids_for_user(user))
+ sessions_from_ids(session_ids_for_user(user.id))
end
- def self.session_ids_for_user(user)
+ def self.session_ids_for_user(user_id)
Gitlab::Redis::SharedState.with do |redis|
- redis.smembers(lookup_key_name(user.id))
+ redis.smembers(lookup_key_name(user_id))
end
end
@@ -129,7 +129,7 @@ class ActiveSession
end
def self.cleaned_up_lookup_entries(redis, user)
- session_ids = session_ids_for_user(user)
+ session_ids = session_ids_for_user(user.id)
entries = raw_active_session_entries(session_ids, user.id)
# remove expired keys.