Ravi Nori has uploaded a new change for review.

Change subject: engine : Transaction issues in CommandsCacheImpl updateStatus
......................................................................

engine : Transaction issues in CommandsCacheImpl updateStatus

When async tasks are executed the updateCommandStatus
is being performed from two different transaction
resulting in transcation lock.

Transaction needs to be suspended before updating
command status.

Change-Id: I3e29d516b4cdf1509ae7838731869684004e5ee9
Signed-off-by: Ravi Nori <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java
1 file changed, 16 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/68/30868/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java
index c44bbb8..1ea5ac3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java
@@ -8,6 +8,9 @@
 import org.ovirt.engine.core.compat.DateTime;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.ovirt.engine.core.utils.transaction.TransactionSupport;
+
+import javax.transaction.Transaction;
 
 public class CommandsCacheImpl implements CommandsCache {
 
@@ -54,7 +57,7 @@
     @Override
     public void put(final CommandEntity cmdEntity) {
         commandMap.put(cmdEntity.getId(), cmdEntity);
-        DbFacade.getInstance().getCommandEntityDao().saveOrUpdate(cmdEntity);
+        saveOrUpdateWithoutTransaction(cmdEntity);
     }
 
     public void removeAllCommandsBeforeDate(DateTime cutoff) {
@@ -67,7 +70,7 @@
         final CommandEntity cmdEntity = get(commandId);
         if (cmdEntity != null) {
             cmdEntity.setCommandStatus(status);
-            
DbFacade.getInstance().getCommandEntityDao().saveOrUpdate(cmdEntity);
+            saveOrUpdateWithoutTransaction(cmdEntity);
         }
     }
 
@@ -79,6 +82,17 @@
         }
     }
 
+    public void saveOrUpdateWithoutTransaction(CommandEntity cmdEntity) {
+        Transaction transaction = TransactionSupport.suspend();
+        try {
+            
DbFacade.getInstance().getCommandEntityDao().saveOrUpdate(cmdEntity);
+        } finally {
+            if (transaction != null) {
+                TransactionSupport.resume(transaction);
+            }
+        }
+    }
+
     public void updateCallBackNotified(final Guid commandId) {
         CommandEntity cmdEntity = get(commandId);
         if (cmdEntity != null) {


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

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

Reply via email to