Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7084463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:18:16+00:00 2026-05-28T07:18:16+00:00

I have a function: def self.run_all_scheduled_reports scheduled_queries = Reports.find( :all, :joins=> ‘INNER JOIN `expected_times`

  • 0

I have a function:

    def self.run_all_scheduled_reports
            scheduled_queries = Reports.find(
                :all,
                :joins=> 'INNER JOIN `expected_times` 
                 ON (`reports`.`report_id` =`expected_times`.`report_id`)')

            if scheduled_queries.empty?
                print "No reports to run at this time ("+Time.now.to_s+")"
            else
                caught_exception = false
                ActiveRecord::Base.connection.execute("SET SESSION WAIT_TIMEOUT=2400");
                scheduled_queries.each do |query|
                    begin
                        print "Running report ("+query[:id].to_s+")...\n"
                        self.run_report(query[:id])
                    rescue Exception => e
                        caught_exception = true
                        print e
                    end
                end
                raise "At least one query resulted in an Exception!" if caught_exception
            end
        end

The weird thing is that, when i run this function consecutively (via script/runner -e …), the result varies. Sometimes about 30 reports are printed while sometimes just 15 (and sometimes, no results at all are returned). You guys have any idea whats happening? My DB is MYSQL.

Also, if i change the environment to “development” OR if i omit the JOIN part, its working pretty well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:18:17+00:00Added an answer on May 28, 2026 at 7:18 am

    I just solved the issue, the inconsistency happens because apparently, my rails is set to use a separate layer/framework to do the db transactions. This middle layer randomly reads from 2 seperate MYSQL boxes, which turned out to be out of sync. Once i synced the 2 boxes, the problem was fixed. Thanks for all the help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a decorated function (simplified version): class Memoize: def __init__(self, function): self.function =
I have a function: def create(sender, **kw): [...] Which should be called when the
I have a function foo that accepts a Boolean function def foo( f:(_)=>Boolean )
I am writing a script and in my script I have this function: def
In python I have the following function: def is_a_nice_element(element, parameter): #do something return True
I have a function like this: def eventcateg_detail(request): ca = EventTypeCategory.objects.values() for i in
I have this function in Python: def Rotate_Vector(vector, axis, direction): where vector is a
I have the following pattern matching case in a scala function: def someFunction(sequences: Iterable[Seq[Int]]):Seq[Int]
I have a function with two optional parameters: def func(a=0, b=10): return a+b Somewhere
I have a function that accepts wildcard keyword parameters: def func(**kargs): doA doB How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.