Michael Kublin has uploaded a new change for review.

Change subject: engine: Disable global trnasaction at ExtendSANStorageDomain
......................................................................

engine: Disable global trnasaction at ExtendSANStorageDomain

During investigation on some bug, I took attentins that we have to many 
transaction time out
exception on ExtendSANStorageDomainCommand.
The problem is that following command is trying to open a global transaction, 
these is a mistake,
transaction is a global resource and should be kept as short as possible.
The change is:
1. Disable global transaction
2. Start to use compensation in order to keep flow correct

Change-Id: I78c4c43c259a58c746caa0402bf5beb004e9a8c2
Signed-off-by: Michael Kublin <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
1 file changed, 34 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/48/11648/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
index 8dcfb2a..4be7cf2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 
 import org.ovirt.engine.core.bll.Backend;
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
 import 
org.ovirt.engine.core.bll.storage.ConnectAllHostsToLunCommand.ConnectAllHostsToLunCommandReturnValue;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters;
@@ -14,36 +15,51 @@
 import org.ovirt.engine.core.common.config.ConfigValues;
 import 
org.ovirt.engine.core.common.vdscommands.ExtendStorageDomainVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.VdcBllMessages;
+import org.ovirt.engine.core.utils.transaction.TransactionMethod;
 
-@SuppressWarnings("serial")
+@NonTransactiveCommandAttribute(forceCompensation = true)
 public class ExtendSANStorageDomainCommand<T extends 
ExtendSANStorageDomainParameters> extends
         StorageDomainCommandBase<T> {
+
+    private static final long serialVersionUID = 5070823228078328883L;
+
+    protected ExtendSANStorageDomainCommand(Guid commandId) {
+        super(commandId);
+    }
+
     public ExtendSANStorageDomainCommand(T parameters) {
         super(parameters);
     }
 
     @Override
     protected void executeCommand() {
-        setStorageDomainStatus(StorageDomainStatus.Locked, null);
-        for (LUNs lun : getParameters().getLunsList()) {
-            proceedLUNInDb(lun, getStorageDomain().getstorage_type(), 
getStorageDomain().getstorage());
-        }
-
+        executeInNewTransaction(new TransactionMethod<Void>() {
+            public Void runInTransaction() {
+                setStorageDomainStatus(StorageDomainStatus.Locked, 
getCompensationContext());
+                getCompensationContext().stateChanged();
+                return null;
+            }
+        });
         boolean supportForceExtendVG = Config.<Boolean> GetValue(
-                ConfigValues.SupportForceExtendVG,  
getStoragePool().getcompatibility_version().toString());
+                ConfigValues.SupportForceExtendVG, 
getStoragePool().getcompatibility_version().toString());
 
-        if (Backend
-                .getInstance()
-                .getResourceManager()
-                .RunVdsCommand(
-                        VDSCommandType.ExtendStorageDomain,
-                        new 
ExtendStorageDomainVDSCommandParameters(getStoragePoolId().getValue(), 
getStorageDomain()
-                                .getId(), getParameters().getLunIds(), 
getParameters().isForce(), supportForceExtendVG))
-                .getSucceeded()) {
-            setStorageDomainStatus(StorageDomainStatus.Active, null);
-            setSucceeded(true);
-        }
+        runVdsCommand(VDSCommandType.ExtendStorageDomain,
+                new 
ExtendStorageDomainVDSCommandParameters(getStoragePoolId().getValue(), 
getStorageDomain()
+                        .getId(), getParameters().getLunIds(), 
getParameters().isForce(), supportForceExtendVG));
+        executeInNewTransaction(new TransactionMethod<Void>() {
+            public Void runInTransaction() {
+                for (LUNs lun : getParameters().getLunsList()) {
+                    proceedLUNInDb(lun, getStorageDomain().getstorage_type(), 
getStorageDomain().getstorage());
+                }
+
+                setStorageDomainStatus(StorageDomainStatus.Active, null);
+                getCompensationContext().resetCompensation();
+                return null;
+            }
+        });
+        setSucceeded(true);
     }
 
     @SuppressWarnings("unchecked")


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

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

Reply via email to