Handle pipelined/multi cmds in cluster validator
What does this MR do and why?
This MR allows RedisClusterValidator
to validate an array of commands instead of single commands. Array of commands are validated in the case of pipelines and transactions (MULTI
) -- https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/instrumentation/redis_interceptor.rb#L15. To prepare for transition of redis-cache
to redis cluster/distributed, we need to check and flag out pipeline/transactions which causes cross-slot errors.
See gitlab-com/gl-infra/scalability#2005 (closed)
TODO
addallow_cross_slot_commands
to areas of code which the validator now detects
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Before:
Loading development environment (Rails 6.1.6.1)
[1] pry(main)> Gitlab::Redis::Cache.with do |redis|
[1] pry(main)* redis.multi do |multi|
[1] pry(main)* multi.set('x', 1)
[1] pry(main)* multi.set('y', 1)
[1] pry(main)* end
[1] pry(main)* end
=> ["OK", "OK"]
After:
Loading development environment (Rails 6.1.6.1)
[1] pry(main)> Gitlab::Redis::Cache.with do |redis|
[1] pry(main)* redis.multi do |multi|
[1] pry(main)* multi.set('x', 1)
[1] pry(main)* multi.set('y', 1)
[1] pry(main)* end
[1] pry(main)* end
Gitlab::Instrumentation::RedisClusterValidator::CrossSlotError: Redis command PIPELINE/MULTI arguments hash to different slots. See https://docs.gitlab.com/ee/development/redis.html#multi-key-commands
from /Users/sylvesterchin/work/gitlab-development-kit/gitlab/lib/gitlab/instrumentation/redis_cluster_validator.rb:198:in `validate!'
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.