| 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 |
|---|