Changeset 1768

Show
Ignore:
Timestamp:
08/26/08 16:32:19 (3 months ago)
Author:
kindlund
Message:

Possible fix for 'Deadlock found' exception, when DroneJob cache counters are changed by more than one process instance simultaneously.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hive/trunk/data_webapp/app/controllers/hc_database_controller.rb

    r1731 r1768  
    137137            if not hu.nil? 
    138138              jobs.each do |job| 
    139                 CompletedUrl.new(:history_url => hu,:drone_job => job).save! 
     139 
     140                # There's a small chance that another process instance may have simultaneouly updated 
     141                # the same DroneJob object, in which case, we'll get a 'Deadlock found' exception. 
     142                # In this case, we simply retry the creation operation until it succeeds. 
     143                while true 
     144                  begin  
     145                    CompletedUrl.new(:history_url => hu,:drone_job => job).save! 
     146 
     147                    # We've successfully created a CompletedUrl object; break out of loop. 
     148                    break 
     149                  rescue 
     150                    if $!.to_s.index('Deadlock found').nil? 
     151                      # If we encounter something other than a "Deadlock found" exception, then 
     152                      # propagate the error. 
     153                      raise $!.to_s 
     154                    end 
     155                  end 
     156                end 
    140157              end 
    141158            end