Hi
Today I got an alert mail from my watcher script, telling me that there
was no
Mongrel running, and that it started one (so the site was down for a few
seconds.)
This is the first time I got this error (AFAICS), but I’d like to
resolve and
prevent it for the future.
From mongrel.log:
** Starting Mongrel listening at 0.0.0.0:foo
** Starting Rails with production environment…
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no
restart).
** Rails signals registered. HUP => reload (without restart). It might
not work well.
** Mongrel available at 0.0.0.0:foo
** Writing PID file to
/home/foo/skatestuff_freebox/releases/20080319193713/tmp/pids/dispatch.foo.pid
/home/foo/skatestuff_freebox/releases/20080319193713/vendor/rails/activerecord/lib/active_record/transactions.rb:76:in
transaction': Transaction aborted (ActiveRecord::Transactions::TransactionError) from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in
call’
from
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in
join' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in
join’
from
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in
each' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in
join’
from
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:136:in
run' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in
run’
from
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
from /usr/local/bin/mongrel_rails:16:in `load’
from /usr/local/bin/mongrel_rails:16
“Transaction aborted” is in
activerecord/lib/active_record/transactions.rb:
module ClassMethods
def transaction(&block)
previous_handler = trap(‘TERM’) { raise TransactionError,
“Transaction aborted” }
increment_open_transactions
begin
connection.transaction(Thread.current['start_db_transaction'],
&block)
ensure
decrement_open_transactions
trap(‘TERM’, previous_handler)
end
end
[…]
Above this, there’s
“Both Base#save and Base#destroy come wrapped in a transaction […]”
and
“Also have in mind that exceptions thrown within a transaction block
will be
propagated […], so you should be ready to catch those in your
application
code.”
The site is not public yet (there still is a site-wide password), so I
can be
quite sure that there was no save or destroy called in my app code.
(By the way, in config/environments/production.rb I have
config.log_level = :warn
but the error was not logged in log/production.log .
And in in config/environment.rb I have
config.action_controller.session_store = :active_record_store
)
Could it be that the error occured when some session data was saved?
In actionpack/lib/action_controller/session/active_record_store.rb there
is
def update
if @session
ActiveRecord::Base.silence { @session.save }
end
end
The “silence” part would explain why there is no error message in
the production.log .
Not sure whether I’m on the right track …
Anyways: How to prevent this error in the future?
Tobi