Hi Pat,
Sorry for not updating this thread. It turned out my search controller was
at fault. Object searched was not being released properly. Here's the code I
can share with others, before and after:
Before
=============
def index
case params[:type]
when 'food'
spots = Spot.foods.order_by('rating_average DESC')
when 'places'
spots = Spot.places.order_by('rating_average DESC')
when 'accommodation'
spots = Spot.accommodations.order_by('rating_average DESC')
else
spots = Spot.latest
end
if params[:filter] == 'on'
spots.clear
country = params[:country] == 'All' ? {} : {:country =>
params[:country]}
case params[:order]
when 'rating_descend'
order = {:order => 'rating_average DESC'}
when 'rating_ascend'
order = {:order => 'rating_average ASC'}
else
order = {}
end
# ThinkingSphinx search
spots = Spot.search params[:keyword], {:conditions => {:spot_type =>
params[:type]}.merge(country)}.merge(order)
end
@spots = spots.paginate(:page => params[:per_page])
end
After
=========
def index
if params[:filter] == 'on'
query = params[:country] == 'All' ? {} : {:country =>
params[:country]}
case params[:order]
when 'rating_descend'
order = {:order => 'rating_average DESC'}
when 'rating_ascend'
order = {:order => 'rating_average ASC'}
else
order = {}
end
query.merge!({:spot_type => params[:type]}) unless
(params[:type]).blank?
# ThinkingSphinx search
@spots = Spot.search params[:keyword], {:conditions => query, :page =>
params[:page], :per_page => 20}.merge(order)
else
@spots = case params[:type]
when 'food'
Spot.paginate(:conditions => ["spot_type=?", "food"], :page =>
params[:page], :per_page => 20, :order => 'created_at DESC')
when 'places'
Spot.paginate(:conditions => ["spot_type=?", "places"], :page =>
params[:page], :per_page => 20, :order => 'created_at DESC')
when 'accommodation'
Spot.paginate(:conditions => ["spot_type=?", "accommodation"],
:page => params[:page], :per_page => 20, :order => 'created_at DESC')
else
Spot.paginate(:conditions => ["created_at between ? and ?",
Time.zone.now - 3.month, Time.zone.now], :page => params[:page], :per_page
=> 20)
end
end
end
On Sun, Nov 21, 2010 at 2:17 PM, Pat Allan <[email protected]> wrote:
> Hi Victor
>
> I've never seen that error message - nor am I sure it belongs to Sphinx
> (although I guess it could be from Passenger/Apache waiting on Sphinx).
>
> What does your search query look like? And the related define_index blocks?
>
> Cheers
>
> --
> Pat
>
> On 18/11/2010, at 1:26 AM, Victor wrote:
>
> > Hi Pat,
> >
> > Ever since I populated my table with 200,000+ entries, indexing has
> > been causing high disk IO rate. I have since reduced the frequency,
> > and it seems looks fine.
> >
> > However, when it comes to search/will_paginate, it took ages to load
> > the page, and most of the time it returns 500 Internal Server Error,
> > or causes Passenger to crash. I checked my Apache error log, and it
> > says:
> >
> > No data received from the backend application (process 3753) within
> > 300000 msec. Either the backend application is frozen, or your TimeOut
> > value of 300 seconds is too low. Please check whether your application
> > is frozen, or increase the value of the TimeOut configuration
> > directive.
> >
> > and...
> >
> > [ pid=3544 file=ext/apache2/Hooks.cpp:706 time=2010-11-17
> > 20:46:41.780 ]:
> > The backend application (process 3733) did not send a valid HTTP
> > response; instead, it sent nothing at all. It is possible that it has
> > crashed; please check whether there are crashing bugs in this
> > application.
> >
> > Any way to go around this? Thanks.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.