[Ovirt-devel] ovirt-server patch for error 'Attempted to update a stale object'

Ian Main imain at redhat.com
Thu Jan 15 23:09:33 UTC 2009


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!

	Ian




More information about the ovirt-devel mailing list