Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:23:20+00:00 2026-05-27T06:23:20+00:00

I am in the middle of upgrading an old Rails and PostgreSQL app from

  • 0

I am in the middle of upgrading an old Rails and PostgreSQL app from 2.1 to Rails 3 (via a successful intermediate 2.3.11 step).

Finally, when I got all the Rspecs running smoothly, I installed Mongrel 1.2.0.pre2 and got it up and running – all OK. Even the JMeter test case with 100 concurrent users passed OK.

But when I tried the same with Unicorn! server, it works fine when I am using it myself, but when I get it under load with JMeter, it starts giving 100% errors from the moment, where JMeter tries to POST a login. At the same time when I check some specific page, it gives me weird errors like this:

undefined method `eq' for nil:NilClass

At the terminal I get the following output (but only a few times):

message type 0x43 arrived from server while idle
message type 0x5a arrived from server while idle
WARNING:  there is already a transaction in progress

EDIT: this seems to be an issue with shared PGconnect object, so I removed some of previous text

I found that PostgreSQL docs specify that PGconn object must not be shared between threads making concurrent requests.

Is Unicorn! or AR mixing requests from different threads in the same PGconn object?

Database.yml:

production:
  adapter: postgresql
  encoding: unicode
  database: ***
  username: ***
  password: ***
  host: 127.0.0.1

I even tried to add this to no avail:

  allow_concurrency: true

unicorn.conf:

worker_processes 8
working_directory "/full/path/to/app"
listen '/tmp/app.sock', :backlog => 512
timeout 30
pid "/full/path/to/app/tmp/pids/puppetmaster_unicorn.pid"

preload_app true
  if GC.respond_to?(:copy_on_write_friendly=)
  GC.copy_on_write_friendly = true
end

Specs:

  • Rails 3.0.6 (because of deployment env)
  • Unicorn! 4.1.1
  • Nginx 1.0.5
  • pg gem 0.11.0
  • PostgreSQL 9.0.4
  • Mac OS X 10.7.2

If Rails version should be the culprit, of course I can upgrade to the latest. I just started off with what the service provider has.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:23:20+00:00Added an answer on May 27, 2026 at 6:23 am

    It’s critical not to share database connections between processes. When you run Rails with preload_app Rails will establish the AR connection(s) before the unicorn master forks the workers. The example unicorn.conf.rb has a recommendation to disconnect the AR connection in the before_fork hook. AR will automatically reestablish a fresh connection as each worker requires it post-fork.

    excerpt from http://unicorn.bogomips.org/examples/unicorn.conf.rb:

    before_fork do |server, worker|
      # the following is highly recomended for Rails + "preload_app true"
      # as there's no need for the master process to hold a connection
      defined?(ActiveRecord::Base) and
        ActiveRecord::Base.connection.disconnect!
      # ...
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just in the middle of upgrading a large application from Rails 3 to
In the middle of upgrading my working copy from 1.6 to 1.7 I had
I am in the middle of making an app using a PHP web service
I have a middle size query with 500.000 registers from an Oracle to an
I'm in the middle of trying to run an RoR app on my Windows
I'm in the middle of updating some applications from ASP.NET 3.5 to 4.0. The
I am in the middle of moving a permission system from PHP to MySQL
I'm in the middle of building a simple iPhone calendar app, & I really
We are in the middle of upgrading to Auth 2.0 and have noticed a
My company is in the middle of upgrading our build system to use Buckminster

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.