[Ovirt-devel] ovirt-server patch for error 'Attempted to update a stale object'
Chris Lalancette
clalance at redhat.com
Fri Jan 16 07:55:34 UTC 2009
Ian Main wrote:
> On Thu, 15 Jan 2009 18:15:10 +0300 Василец Дмитрий <d.vasilets at peterhost.ru>
> wrote:
>
>> patch for error 'Attempted to update a stale object'
>>
>> diff --git a/src/task-omatic/task_vm.rb b/src/task-omatic/task_vm.rb index
>> c187287..fddc594 100644 --- a/src/task-omatic/task_vm.rb +++
>> b/src/task-omatic/task_vm.rb @@ -196,8 +196,18 @@ def create_vm_xml(name,
>> uuid, memAllocated, memUsed, vcpus, bootDevice, end
>>
>> def setVmState(vm, state) - vm.state = state - vm.save! + attempts = 0 +
>> begin + vm.state = state + vm.save! + rescue
>> ActiveRecord::StaleObjectError + puts "error with stale object" + if
>> attempts < 3 + attempts += 1 + vm.reload + retry + end +
>> end end
>
> Interesting. I know when doing certain long operations it can fail; never
> considered catching that and doing a retry. I'll push a similar patch
> shortly. I may just remove the puts and I'm not sure how many attempts we
> want to make? Anyway I'll play with it. Thanks!
This doesn't actually make sense to me, though; isn't a StaleObject exception
actually a sign of some deeper problem? The last time I started getting these,
it was indeed a problem; I was removing an object (with object.delete), and then
later modifying the object, which was throwing these exceptions. I think we
need to understand why we are getting a StaleObject first (or am I completely
missing what's going on here?).
--
Chris Lalancette
More information about the ovirt-devel
mailing list