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

Василец Дмитрий d.vasilets at peterhost.ru
Thu Jan 15 15:15:10 UTC 2009


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
 
 def setVmVncPort(vm, domain)





More information about the ovirt-devel mailing list