brandonhilkert / sucker_punch

Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
MIT License
2.65k stars 114 forks source link

Test suite throwing connection timeout #138

Closed AldanaQuintana closed 8 years ago

AldanaQuintana commented 8 years ago

Hi. Not sure if this is really an issue or if we are doing something wrong. I've searched the internet for help but we are still struggling with this problem...

We are using sucker punch to send emails on background and to process some responses of external services asynchronously. We also wrote some tests, using the configuration suggested on readme.

Everything was working fine until we decided to implement a new actor, that is no different from the others. Now the test suite is throwing "ActiveRecord::ConnectionTimeoutError".

We are using ActiveRecord::Base.connection_pool.with_connection method passing a block to it in almost every actor because most of them interact with database. In addition, we usually handle some business related exceptions inside of that block. Like this:

def perform
  ActiveRecord::Base.connection_pool.with_connection do
    begin
      ... # do something
    rescue SomeException => e
      ... # handle exception
    end
  end
end

I've posted a question on stack overflow, and will keep this updated if we find a solution.

Thank you in advance.

brandonhilkert commented 8 years ago

Have you tried configuring the ActiveRecord connection pool to be larger?

AldanaQuintana commented 8 years ago

No, I haven't. And I realize why this would be a solution. But since I don't understand the underlying problem I don't know if this would be just like hiding it.

brandonhilkert commented 8 years ago

The problem seems to be obtaining a connection. Spawning a good amount of threads that interact with the DB will use up connections. I don't know the specifics of how many you have setup and the number of jobs in the system, but it sounds related to your current database adapter settings.


_Build a Ruby Gem is available! http://brandonhilkert.com/books/build-a-ruby-gem/?utm_source=gmail-sig&utm_medium=email&utm_campaign=gmail_

http://brandonhilkert.com

On Mon, Nov 9, 2015 at 12:48 PM, AldanaQuintana notifications@github.com wrote:

No, I haven't. And I realize why this would be a solution. But since I don't understand the underlying problem I don't know if this would be just like hiding it.

— Reply to this email directly or view it on GitHub https://github.com/brandonhilkert/sucker_punch/issues/138#issuecomment-155137896 .