resque / resque/resque-pool

Automatically manage known-common DB connections

Open
#135 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
456
Forks
149
Avg merge
9d 7h
Merged PRs (30d)
3

Description

Specifically, check for defined? ActiveRecord::Base and Resque.redis. Then we can remove those bits from the necessary config for probably 95% of users (and remove one of the most common misconfigurations). Any other connections will still need to be managed manually (and we will still need to document this in the README).

We should do a quick search for open TCP sockets and issue a warning if any of them were shared from the master. e.g.

# helper
def open_tcp_sockets
  return [] if configured_to_ignore_open_socket_warnings?
  ObjectSpace.each_object(TCPSocket).each_with_object({}) do |f,h|
    fd = f.fileno rescue nil  
    h[fd] = f if fd && (!f.closed? rescue nil)
end

# immediately after fork
tcp_from_master = open_tcp_sockets

# after running the after fork hooks
current_open_tcp_fds = open_tcp_socket_fds.keys
(tcp_from_master.keys & current_open_tcp_fds).each do |fd|
  socket = tcp_from_master[fd]
  unless configured_to_ignore_warning_for?(socket)
    print_warning_for(socket)
  end
end

We could also extend this to open File, IO, UDPSocket, etc, but those are more likely to be legitimately shared between master/worker.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the fork and after-fork hook code, then inspect the connection configuration and README references mentioned in the issue. Confirm how ActiveRecord::Base and Resque.redis are detected, and define done as automatic handling for those connections plus a warning for inherited open TCP sockets, with the README updated for remaining manual cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.