Why is Rails dropping the Postgres connection on large bulk inserts?

本小妞迷上赌 提交于 2019-12-24 14:34:52

问题


I'm brand-spanking new to the world of linux and server administration, and I'm stuck.

I have a rails app that occasionally needs to perform large data inserts, usually around 20,000 rows. The code seems to work fine in development (osx), but on the production servers (ubunto, on a linode vps), it fails every time, usually after about 1,700 insertions. The precise number varies (1655, 1697, 1756), but it's consistently in that ballpark.

I'm not seeing much that's helpful in the production.log file. just:

Connecting to database specified by database.yml

a second or so after it fails.

In the postgresql main log:

2012-10-21 23:01:28 EDT LOG:  could not receive data from client: Connection reset by peer
2012-10-21 23:01:28 EDT LOG:  unexpected EOF on client connection

I'm running Rails 3.2.8, ruby 1.9.3-p194, psql 1.9.4, nginx, unicorn

Really following deployment steps outlined in: http://railscasts.com/episodes/335-deploying-to-a-vps

Other notes:

a) I've tried wrapping and not wrapping the ActiveRecord insertions in a transaction. No differnece.

b) Ruby is doing a lot work to gather and organize the data before inserting to the db. This includes multiple calls to a third party web service. But I've confirmed that these communications are successful, and the data looks fine.

Any ideas? Or at least any suggestions as to where I can continue sleuthing? Thanks so much,


回答1:


The moral of the story is: "When in doubt, blame unicorns."

(Unicorn was set to timeout worker processes after 30 seconds.)



来源:https://stackoverflow.com/questions/13004664/why-is-rails-dropping-the-postgres-connection-on-large-bulk-inserts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!