# TransactionError

**URL:** <https://discuss.rubyonrails.org/t/transactionerror/27560>\
**Category:** rubyonrails-talk\
**Created:** [April 4, 2008, 4:09pm UTC](https://discuss.rubyonrails.org/t/transactionerror/27560 "2008-04-04T16:09:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tobi\_Reif](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Tobi\_Reif](https://discuss.rubyonrails.org/u/Tobi_Reif)\
**Post date:** [April 4, 2008, 4:09pm UTC](https://discuss.rubyonrails.org/t/transactionerror/27560/1 "2008-04-04T16:09:54Z")

</div>

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) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in `call' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in `join' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in `join' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in `each' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:293:in `join' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel\_rails:136:in `run' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel\_rails:243 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/bin/mongrel\_rails:16:in `load' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /usr/local/bin/mongrel\_rails:16

"Transaction aborted" is in activerecord/lib/active\_record/transactions.rb:

&nbsp;&nbsp;module ClassMethods &nbsp;&nbsp;&nbsp;&nbsp;def transaction(&block) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;previous\_handler = trap('TERM') { raise TransactionError, "Transaction aborted" } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;increment\_open\_transactions

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connection.transaction(Thread.current['start\_db\_transaction'], &block) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ensure &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;decrement\_open\_transactions &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;trap('TERM', previous\_handler) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;[...]

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

&nbsp;&nbsp;config.log\_level = :warn

but the error was not logged in log/production.log .

And in in config/environment.rb I have

&nbsp;&nbsp;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

&nbsp;&nbsp;def update &nbsp;&nbsp;&nbsp;&nbsp;if @session &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ActiveRecord::Base.silence { @session.save } &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;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

---

<div class="post-metadata">

**Author:** ![Tobi\_Reif](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Tobi\_Reif](https://discuss.rubyonrails.org/u/Tobi_Reif)\
**Post date:** [April 8, 2008, 8:59am UTC](https://discuss.rubyonrails.org/t/transactionerror/27560/2 "2008-04-08T08:59:03Z")

</div>

Hi

Any idea how to prevent this error?

Tobi

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [April 8, 2008, 9:38am UTC](https://discuss.rubyonrails.org/t/transactionerror/27560/3 "2008-04-08T09:38:32Z")

</div>

> Hi
> 
> Any idea how to prevent this error?
> 
> Tobi
> 
> > 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.

Can you figure out from your logs what your server was doing when this  
happened? Could anything else have sent a TERM signal to your mongel  
(eg something that kills processes if they are using excessive memory?

Fred
