In unix, when a child is forked off from the parent, it inherits its
parent's file descriptors (and thus sockets), and it's very bad to
re-use these in the child process.  The rails code is probably ensuring
that children don't re-use their parents' sockets, and I wanted to make
sure that it works as expected.

On Mon, Sep 30, 2013 at 02:07:44PM -0700, Lukasz Krystkowiak wrote:
> > -  end
> > -end
> > -
> > -ActiveRecord::Base.singleton_class.class_eval do
> > -  def establish_connection_with_connection_pool_name(spec = nil)
> > -    case spec
> > -    when ActiveRecord::Base::ConnectionSpecification
> > -      connection_handler.establish_connection(connection_pool_name, spec)
> > -    else
> > -      establish_connection_without_connection_pool_name(spec)
> > -    end
> > -  end
> > -  alias_method_chain :establish_connection, :connection_pool_name
> > -end
> > +module ActiveRecordShards
> > +  ConnectionPoolNameDecorator = Struct.new(:name)
> 
> @osheroff I don't see what role sockets play here. As far as I understand `pool_from_any_process_for`, it uses only copied memory from a parent process. Is it how you see it or I'm missing sth obvious here?
> 
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/zendesk/active_record_shards/pull/5/files#r6671278