Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis is polluted when GlobalId is used to pass arguments #3

Open
loveapoex opened this issue Nov 5, 2018 · 1 comment
Open

Redis is polluted when GlobalId is used to pass arguments #3

loveapoex opened this issue Nov 5, 2018 · 1 comment

Comments

@loveapoex
Copy link

Documentation taken from here

image

How to recreate

class UpdateUserJob < ActiveJob::Base
  include ActiveJobLock::Core

  lock loner: true

  def perform(user)
    user.update_something_important
  end
end

Enqueue Job:

user = User.first

puts user.to_s
=> "#<User:0x00007f9101f10c90>"

UpdateUserJob.perform_later(user)

Check locks:

redis-cli KEYS "loner:lock:UpdateUserJob:*"
loner:lock:UpdateUserJob:#<User:0x00007f9101f10c90>

Wait for job to be processed by workers...
Check locks:

redis-cli KEYS "loner:lock:UpdateUserJob:*"
loner:lock:UpdateUserJob:#<User:0x00007f9101f10c90>

Problem

redis_loner_lock_key generates different keys when called from enqueue and perform when relying on GlobalId to pass ActiveRecord objects as parameters, which causes Redis to be polluted.

@Startouf
Copy link

Startouf commented Dec 12, 2018

There seem to be another redis-based gem out there that already deals with GlobalId https://github.com/erickrause/activejob-locks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants