1

Using ruby ruby 1.9.3p194, rails 3.2.8, postgresql 9.2

The controller dies with this query

@jobs = Job.select([:user_id, :job_actual_wall_time, :job_processor_count, :job_requested_memory, :job_started_at, :job_ended_at]).joins(:account).where("(job_started_at between :start_date and :end_date) or 
   (job_ended_at between :start_date and :end_date  ) or 
   (job_started_at < :start_date and job_ended_at > :end_date)", 
   {start_date: @start_date, end_date: @end_date}).where(:account_id => account_id).order(:user_id).order(:job_started_at)

where @start_date is July 1, 2012 and @end_date is July 4, 2012 and account_id = 8

I can set the variables by hand at the console and the query executes without error (there are about 95,000 jobs in that interval). If I set the end date back by a day, there are about 50,000 such jobs and in rails the query executes. It seems to be the number of records requested.

Not sure where to debug this one. There doesn't seem to be a question quite like this on SO; but if there is, please point me to it.

thisfeller
  • 788
  • 1
  • 5
  • 15
  • do you have any other gems installed? Based on http://stackoverflow.com/questions/12342691/upgrading-to-rails-3-2-8-causes-stack-level-too-deep-error-with-activerecord and http://stackoverflow.com/questions/13220807/rails-stack-level-too-deep-error if you're using SearchLogic gem, it is likely the cause – Krease Nov 15 '12 at 18:46
  • Not sure about your issue but you can make your code more readable by replacing `.where(['field1 < ? and field2 > ?', start, stop])` by `.where(['field1 < :begin and field2 > :end', {begin: start, end: stop}])` this way you can remove all the repeated @start_date, @end_date – Adrien Coquio Nov 15 '12 at 18:46
  • Not using the SearchLogic gem. – thisfeller Nov 15 '12 at 18:51
  • I used the format I did with the sql because of the "or" conditions. – thisfeller Nov 15 '12 at 18:52
  • You can still use it, see [pastie](http://pastie.org/5383762) – Adrien Coquio Nov 15 '12 at 19:00
  • Hey. Thanks for that simplification. I will edit the question. However, the query still fails when the end date is July 4th, or beyond. – thisfeller Nov 15 '12 at 19:05

0 Answers0