Maor Lipchuk has uploaded a new change for review.

Change subject: core: Execute clear tasks with new thread.
......................................................................

core: Execute clear tasks with new thread.

clearAsyncTasksWithOutVdsmId is executed at the finally step when
executing a vdc command.
If the execute phase encountered a problem, the engine sets the
transaction to rollback only and we can not use it any more.
Since the clearAsyncTasksWithOutVdsmId uses calls to the DB, the engine
throws an EJBTransactionRolledbackException, and the original exception does not
seep to the user.

The proposed solution is to clear the async tasks with a new
transaction, so it will not be dependent on the related execute phase.

Change-Id: I3434c2dbd605e741b2cfbbede8c4a120f21ca9fe
Bug-Url: https://bugzilla.redhat.com/1037441
Signed-off-by: Maor Lipchuk <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
1 file changed, 14 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/23911/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
index 3588e6f..ceeaefe 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
@@ -362,11 +362,20 @@
     }
 
     private void clearAsyncTasksWithOutVdsmId() {
-        for (Guid asyncTaskId : getReturnValue().getTaskPlaceHolderIdList()) {
-            AsyncTasks task = getAsyncTaskDao().get(asyncTaskId);
-            if (task != null && Guid.isNullOrEmpty(task.getVdsmTaskId())) {
-                AsyncTaskManager.removeTaskFromDbByTaskId(task.getTaskId());
-            }
+        if (!getReturnValue().getTaskPlaceHolderIdList().isEmpty()) {
+            TransactionSupport.executeInNewTransaction(new 
TransactionMethod<Void>() {
+                @Override
+                public Void runInTransaction() {
+                    for (Guid asyncTaskId : 
getReturnValue().getTaskPlaceHolderIdList()) {
+                        AsyncTasks task = getAsyncTaskDao().get(asyncTaskId);
+                        if (task != null && 
Guid.isNullOrEmpty(task.getVdsmTaskId())) {
+                            
AsyncTaskManager.removeTaskFromDbByTaskId(task.getTaskId());
+                        }
+
+                    }
+                    return null;
+                }
+            });
         }
     }
 


-- 
To view, visit http://gerrit.ovirt.org/23911
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3434c2dbd605e741b2cfbbede8c4a120f21ca9fe
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Maor Lipchuk <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to