documentcloud / cloud-crowd

Parallel Processing for the Rest of Us

Home Page:https://github.com/documentcloud/cloud-crowd/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AR connection pool exhaustion

knowtheory opened this issue · comments

Because the CloudCrowd server forks off processes using Thread.new in order to prevent the server from blocking, new threads claim an AR connection, but never notify the connection pool when the thread is finished with a connection.

Consequently, if more jobs are quickly submitted than there are connections in the pool, the server freaks out at the empty connection pool. A similar problem is documented in a variety of places:

The solution we're going with is providing an abstraction that takes a block, wraps it inside an explicit AR connection inside of a thread as mperham points out here: sidekiq/sidekiq#1047 (comment)

It'll probably be called CloudCrowd.defer.

This was fixed in 38aaaef, and has been running without issues for several months now, closing the issue.