# Random SystemExit. ActiveRecord::StatementInvalid

**URL:** <https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996>\
**Category:** Rails\
**Created:** [October 28, 2008, 8:21pm UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996 "2008-10-28T20:21:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgarada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@cgarada](https://www.ruby-forum.com/u/cgarada)\
**Post date:** [October 28, 2008, 8:21pm UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996/1 "2008-10-28T20:21:58Z")

</div>

I have this recurrent problem that I just can’t figure out. On several  
parts of the application when active record is executing some query it  
throws a ActiveRecord::StatementInvalid exit like this:

A ActiveRecord::StatementInvalid occurred in  
someapplication#some\_action:

SystemExit: exit: SELECT \* FROM project WHERE (project.`id` = 99999)  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/connection\_adapters/abstract\_adapter.rb:128:in  
`log’

The thing is that the next time you try the same action, it works fine,  
also if you run that query directly in a console or any query browser it  
returns a valid result. The occurrence is very random.

Any help or comments are greatly appreciated.

---

<div class="post-metadata">

**Author:** ![cgarada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@cgarada](https://www.ruby-forum.com/u/cgarada)\
**Post date:** [October 28, 2008, 9:00pm UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996/2 "2008-10-28T21:00:11Z")

</div>

On Oct 28, 7:21 pm, Carlos G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have this recurrent problem that I just can’t figure out. On several  
> parts of the application when active record is executing some query it  
> throws a ActiveRecord::StatementInvalid exit like this:

I may be misremembering, but I have a vague idea that this can happen  
if the mongrel/whatever is sent a TERM signal. How is your app  
deployed? (in particular I seem to remember apache being a little  
enthusiastic about killing fastcgi instances)

Fred

---

<div class="post-metadata">

**Author:** ![cgarada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@cgarada](https://www.ruby-forum.com/u/cgarada)\
**Post date:** [October 28, 2008, 9:22pm UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996/3 "2008-10-28T21:22:18Z")

</div>

Frederick C. wrote:

> On Oct 28, 7:21ï¿½pm, Carlos G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > I have this recurrent problem that I just can’t figure out. On several  
> > parts of the application when active record is executing some query it  
> > throws a ActiveRecord::StatementInvalid exit like this:
> 
> I may be misremembering, but I have a vague idea that this can happen  
> if the mongrel/whatever is sent a TERM signal. How is your app  
> deployed? (in particular I seem to remember apache being a little  
> enthusiastic about killing fastcgi instances)
> 
> Fred

We deploy to virtual hosts using apache on ubuntu.

---

<div class="post-metadata">

**Author:** ![cgarada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@cgarada](https://www.ruby-forum.com/u/cgarada)\
**Post date:** [October 28, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996/4 "2008-10-28T22:02:36Z")

</div>

On 28 Oct 2008, at 20:22, Carlos G.  
\<removed\_email\_address@domain.invalid

> wrote:

> > > 
> > 
> > I may be misremembering, but I have a vague idea that this can happen  
> > if the mongrel/whatever is sent a TERM signal. How is your app  
> > deployed? (in particular I seem to remember apache being a little  
> > enthusiastic about killing fastcgi instances)
> > 
> > Fred
> 
> We deploy to virtual hosts using apache on ubuntu.

But what sits behind that? Mod\_rails, mongrel, fastcgi, scgi?

---

<div class="post-metadata">

**Author:** ![cgarada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@cgarada](https://www.ruby-forum.com/u/cgarada)\
**Post date:** [October 28, 2008, 10:41pm UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996/5 "2008-10-28T22:41:21Z")

</div>

On Oct 28, 9:22 pm, Carlos G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > > Fred
> 
> > > We deploy to virtual hosts using apache on ubuntu.
> 
> > But what sits behind that? Mod\_rails, mongrel, fastcgi, scgi?
> 
> hehe, sorry, fastcgi

So as I was saying, I remember apache killing off fastcgi instances. I  
think it logs (or can be told to log) when it does this. If you can  
correlate this with when you get the errors then you’ll have found  
your cause.

Fred

---

<div class="post-metadata">

**Author:** ![cgarada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@cgarada](https://www.ruby-forum.com/u/cgarada)\
**Post date:** [November 5, 2008, 3:21am UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996/6 "2008-11-05T03:21:44Z")

</div>

Frederick C. wrote:

> On Oct 28, 9:22ï¿½pm, Carlos G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > > > > Fred
> > 
> > > > We deploy to virtual hosts using apache on ubuntu.
> > 
> > > But what sits behind that? Mod\_rails, mongrel, fastcgi, scgi?
> > 
> > hehe, sorry, fastcgi
> 
> So as I was saying, I remember apache killing off fastcgi instances. I  
> think it logs (or can be told to log) when it does this. If you can  
> correlate this with when you get the errors then you’ll have found  
> your cause.
> 
> Fred

Hi,

I have the same problem… I am planning to speed up the query. Will it  
help??

Regards  
Selva

---

<div class="post-metadata">

**Author:** ![cgarada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@cgarada](https://www.ruby-forum.com/u/cgarada)\
**Post date:** [October 28, 2008, 10:22pm UTC](https://www.ruby-forum.com/t/random-systemexit-activerecord-statementinvalid/151996/7 "2008-10-28T22:22:19Z")

</div>

Frederick C. wrote:

> On 28 Oct 2008, at 20:22, Carlos G.  
> \<removed\_email\_address@domain.invalid
> 
> > wrote:
> 
> > > > 
> > > 
> > > I may be misremembering, but I have a vague idea that this can happen  
> > > if the mongrel/whatever is sent a TERM signal. How is your app  
> > > deployed? (in particular I seem to remember apache being a little  
> > > enthusiastic about killing fastcgi instances)
> > > 
> > > Fred
> > 
> > We deploy to virtual hosts using apache on ubuntu.
> 
> But what sits behind that? Mod\_rails, mongrel, fastcgi, scgi?

hehe, sorry, fastcgi
