Skip to content

Redis connections are left open #5

@bkroeker

Description

@bkroeker

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions