Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-16 18:10:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-16 18:10:52 +0300
commit0552020767452da44de2bf5424096f2cb2ea6bf5 (patch)
tree9579d9f0ad3c730c33883130ec23420e80d1c5dc /app/models/awareness_session.rb
parente3748b81ca29b24197276767e245158d8f84fda3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/awareness_session.rb')
-rw-r--r--app/models/awareness_session.rb49
1 files changed, 29 insertions, 20 deletions
diff --git a/app/models/awareness_session.rb b/app/models/awareness_session.rb
index cca69e38b6f..0b652984630 100644
--- a/app/models/awareness_session.rb
+++ b/app/models/awareness_session.rb
@@ -63,16 +63,18 @@ class AwarenessSession # rubocop:disable Gitlab/NamespacedClass
user_key = user_sessions_key(user.id)
with_redis do |redis|
- redis.pipelined do |pipeline|
- pipeline.sadd?(user_key, id_i)
- pipeline.expire(user_key, USER_LIFETIME.to_i)
+ Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
+ redis.pipelined do |pipeline|
+ pipeline.sadd?(user_key, id_i)
+ pipeline.expire(user_key, USER_LIFETIME.to_i)
- pipeline.zadd(users_key, timestamp.to_f, user.id)
+ pipeline.zadd(users_key, timestamp.to_f, user.id)
- # We also mark for expiry when a session key is created (first user joins),
- # because some users might never actively leave a session and the key could
- # therefore become stale, w/o us noticing.
- reset_session_expiry(pipeline)
+ # We also mark for expiry when a session key is created (first user joins),
+ # because some users might never actively leave a session and the key could
+ # therefore become stale, w/o us noticing.
+ reset_session_expiry(pipeline)
+ end
end
end
@@ -83,26 +85,33 @@ class AwarenessSession # rubocop:disable Gitlab/NamespacedClass
user_key = user_sessions_key(user.id)
with_redis do |redis|
- redis.pipelined do |pipeline|
- pipeline.srem?(user_key, id_i)
- pipeline.zrem(users_key, user.id)
+ Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
+ redis.pipelined do |pipeline|
+ pipeline.srem?(user_key, id_i)
+ pipeline.zrem(users_key, user.id)
+ end
end
# cleanup orphan sessions and users
#
# this needs to be a second pipeline due to the delete operations being
# dependent on the result of the cardinality checks
- user_sessions_count, session_users_count = redis.pipelined do |pipeline|
- pipeline.scard(user_key)
- pipeline.zcard(users_key)
- end
+ user_sessions_count, session_users_count =
+ Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
+ redis.pipelined do |pipeline|
+ pipeline.scard(user_key)
+ pipeline.zcard(users_key)
+ end
+ end
- redis.pipelined do |pipeline|
- pipeline.del(user_key) unless user_sessions_count > 0
+ Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
+ redis.pipelined do |pipeline|
+ pipeline.del(user_key) unless user_sessions_count > 0
- unless session_users_count > 0
- pipeline.del(users_key)
- @id = nil
+ unless session_users_count > 0
+ pipeline.del(users_key)
+ @id = nil
+ end
end
end
end