Skip to content

Concurrency issue in redis-rb 4.6.0 (using redis-namespace) #1088

@sergio91pt

Description

@sergio91pt

With the upgrade of redis-rb from 4.5.1 to 4.6.0 we started observing ocasional odd behavior under load:

A non-pipelined redis.evalsha(sha, keys, args) returning a Redis::Future instead of a String causing an error when the application tries to parse it.

And occasionally at the same time but in a different thread we noticed a misbehavior when a pipelined exists? wrongly evaluates to true.

(open, half_open) = execute_redis_pipeline { |pipeline|
  pipeline.exists?(open_key(name))
  pipeline.exists?(half_open_key(name))
}
# Both should be false according to our observability metrics

# For reference:
def execute_redis_command
  yield
rescue Redis::BaseError => e
  raise CircuitBreakerError.new(e.message, e)
end

def execute_redis_pipeline(&block)
  execute_redis_command { redis.pipelined(&block) }
end

Although relatively rare they seem related with the redis-rb gem upgrade, since we updated our pipelines and sidekiq dependency to avoid deprecation warnings 1 week before upgrading redis-rb, without problem.

Using:

Ruby 3.0.1
connection_pool (2.2.5)
redis (4.6.0) (default driver, w/ redis sentinel, no cluster)
redis-namespace (1.8.1)
sidekiq (6.4.1)
sidekiq-pro (5.3.1)
newrelic_rpm (7.2.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions