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 connections are left open #5

Open
bkroeker opened this issue Sep 10, 2019 · 1 comment
Open

Redis connections are left open #5

bkroeker opened this issue Sep 10, 2019 · 1 comment

Comments

@bkroeker
Copy link

My app experienced an explosion of redis connections after I started using this gem, which is a problem because the redis service I use has a connection cap. It seems that this gem never disconnects redis connections, nor does it use a redis connection pool. Redis connections are left open until their ruby objects are eventually garbage collected.

The easiest solution for me was to shim some disconnect code into the "unlock" method, since I was overriding the suo gem adapter anyway so I could specify a port and password (see #3).

In this case the relevant code is:

module SuoLockingAdapterExtension
  def unlock
    super
    lock_manager.client.close
  end
end
ActiveJob::Locking::Adapters::SuoRedis.send :prepend, SuoLockingAdapterExtension

Not sure how you want to incorporate that into the gem, but the line of code would presumably be needed by all redis services. I just happen to be using Suo.

@bkroeker
Copy link
Author

(Quantitatively speaking, I was seeing 150+ open connections regularly. My redis service caps at 200, and I never have more than 10 jobs running simultaneously, which is rare.)

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

1 participant