From: Avner Cohen <avner.cohen@fiverr.com>
To: Eric Wong <normalperson@yhbt.net>
Cc: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: preload_app = true causing - ActiveModel::MissingAttributeError: missing attribute: some_attr
Date: Sun, 20 Jan 2013 10:10:27 +0200 [thread overview]
Message-ID: <CAAZOLpVqKHZ_jDewirTPCmV_ictqaJSjGJi208HFZyfMS2jR1Q@mail.gmail.com> (raw)
In-Reply-To: <20130120080431.GA1283@dcvr.yhbt.net>
Eric,
Thanks for the quick reply, and aplogies for not providing full info.
I do have these set up, here is my full configuration:
# -*- encoding : utf-8 -*-
worker_processes 4
working_directory "."
listen 3000
timeout 120
preload_app true
before_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
Best Regards,
Avner Cohen
On Sun, Jan 20, 2013 at 10:04 AM, Eric Wong <normalperson@yhbt.net> wrote:
> Avner Cohen <avner.cohen@fiverr.com> wrote:
>> Greetings,
>>
>> I'm getting this - ActiveModel::MissingAttributeError: missing
>> attribute: some_attr - on a random basis under a unicorn server,
>> running rails 3.2 and ruby 1.9.3
>> As the case of the last poster in the following thread -
>> https://github.com/rails/rails/issues/1906 - I too am able to resolve
>> this issue by settingpreload_app to false.
>>
>> However, this is not the behaviour I want to have.
>>
>> Any inputs on that, or data I can provide around this issue?
>
> Did you try disconnecting in your before_fork hook and reconnecting
> after_fork?
>
> 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
>
> after_fork do |server, worker|
> # the following is *required* for Rails + "preload_app true",
> defined?(ActiveRecord::Base) and
> ActiveRecord::Base.establish_connection
> end
>
> Open database handles must not be carried across fork.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying
next prev parent reply other threads:[~2013-01-20 8:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-20 7:36 preload_app = true causing - ActiveModel::MissingAttributeError: missing attribute: some_attr Avner Cohen
2013-01-20 8:04 ` Eric Wong
2013-01-20 8:10 ` Avner Cohen [this message]
2013-01-20 9:17 ` Eric Wong
2013-01-20 21:39 ` Lawrence Pit
2013-01-21 7:55 ` Avner Cohen
2013-01-21 8:11 ` Lawrence Pit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAZOLpVqKHZ_jDewirTPCmV_ictqaJSjGJi208HFZyfMS2jR1Q@mail.gmail.com \
--to=avner.cohen@fiverr.com \
--cc=mongrel-unicorn@rubyforge.org \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).